[IMP]Invoice: on change account in invoice line did not shows the taxes of the change...
authorSomesh Khare <skh@tinyerp.com>
Tue, 11 Dec 2012 05:28:54 +0000 (10:58 +0530)
committerSomesh Khare <skh@tinyerp.com>
Tue, 11 Dec 2012 05:28:54 +0000 (10:58 +0530)
bzr revid: skh@tinyerp.com-20121211052854-wtqzljpb9gn4yavt

1  2 
addons/account/account_invoice.py

@@@ -1356,15 -1356,20 +1356,18 @@@ class account_invoice_line(osv.osv)
              context.update({'lang': part.lang})
          result = {}
          res = self.pool.get('product.product').browse(cr, uid, product, context=context)
          if type in ('out_invoice','out_refund'):
-             a = res.product_tmpl_id.property_account_income.id
-             if not a:
-                 a = res.categ_id.property_account_income_categ.id
 -            if 'account_id' not in context:
+                 a = res.product_tmpl_id.property_account_income.id
+                 if not a:
+                     a = res.categ_id.property_account_income_categ.id
 -            else:  
 -                 a = context.get('account_id')
          else:
-             a = res.product_tmpl_id.property_account_expense.id
-             if not a:
-                 a = res.categ_id.property_account_expense_categ.id
 -            if 'account_id' not in context:
+                 a = res.product_tmpl_id.property_account_expense.id
+                 if not a:
+                     a = res.categ_id.property_account_expense_categ.id
 -            else:
 -                a = context.get('account_id')
++        
++        if context.get('account_id',False):
++             a = context.get('account_id')
++            
          a = fpos_obj.map_account(cr, uid, fpos, a)
          if a:
              result['account_id'] = a
      #
      # Set the tax field according to the account and the fiscal position
      #
 -    def onchange_account_id(self, cr, uid, ids, product_id, partner_id, inv_type, fposition_id, account_id,context=None):
 -        if context is None:
 -            context ={}
 +    def onchange_account_id(self, cr, uid, ids, product_id, partner_id, inv_type, fposition_id, account_id):
++
          if not account_id:
              return {}
 -        else:
 -            context.update(account_id = account_id)
++        ctx= {}
          unique_tax_ids = []
          fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
          account = self.pool.get('account.account').browse(cr, uid, account_id)
              taxes = account.tax_ids
              unique_tax_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
          else:
++            ctx.update(account_id = account_id)
              product_change_result = self.product_id_change(cr, uid, ids, product_id, False, type=inv_type,
-                 partner_id=partner_id, fposition_id=fposition_id,
 -                partner_id=partner_id, fposition_id=fposition_id,context=context,
++                partner_id=partner_id, fposition_id=fposition_id,context=ctx,
                  company_id=account.company_id.id)
              if product_change_result and 'value' in product_change_result and 'invoice_line_tax_id' in product_change_result['value']:
                  unique_tax_ids = product_change_result['value']['invoice_line_tax_id']