← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 613567] Re: [trunk] bank statement - wrong account proposed

 

** Changed in: openobject-addons
   Importance: Undecided => Low

** Changed in: openobject-addons
       Status: New => Confirmed

** Changed in: openobject-addons
     Assignee: (unassigned) => OpenERP R&D Addons Team 3 (openerp-dev-addons3)

-- 
[trunk] bank statement - wrong account proposed
https://bugs.launchpad.net/bugs/613567
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.

Status in OpenObject Addons Modules: Confirmed

Bug description:
on change of partner fills the account_id - but always with the debtor account

in v5 https://code.launchpad.net/~openerp-commiter/openobject-addons/chricar_price_unit
i have modified the code
* to check if a partner is customer or supplier
* select the appropriate account_id if partner is customer OR supplier
* request to select an account if partner is customer AND supplier

BTW this should be done also elsewhere where account move lines with partner are encoded

    def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id,
            context={}):
        if not partner_id:
            return {}
        res_currency_obj = self.pool.get('res.currency')
        res_users_obj = self.pool.get('res.users')

        company_currency_id = res_users_obj.browse(cursor, user, user,
                context=context).company_id.currency_id.id

        if not currency_id:
            currency_id = company_currency_id

        part = self.pool.get('res.partner').browse(cursor, user, partner_id,
                context=context)

        # quick FIXME check what partner is defined in partner and override input
        if type == 'partner' :  # trigger runs from partner
            type = 'general'
            if not part.supplier and not part.customer :
                print 'Partner should be customer and/or supplier'

            if part.supplier == True and part.customer == True :
                #type = '' # manual entry necessary FIXME - currently general remains in this case visible - no way to get the select field empty
                type = 'general'
                print 'Wizard missing - User has to choose category'
            else:
                if part.supplier == True :
                    type = 'supplier'
                if part.customer == True :
                    type = 'customer'

        account_id = ''
        if type == 'supplier':
            account_id = part.property_account_payable.id
        if type == 'customer':
            account_id =  part.property_account_receivable.id

may be there is a better technical solution - moving (part of) this code to partner.py