[FIX] Account/stock : Better context-handling at tax computation to avoid wrong context-passing

bzr revid: jvo@tinyerp.com-20101006142745-hosp53x09d6hjnr5
This commit is contained in:
Jay (OpenERP) 2010-10-06 19:57:45 +05:30
parent f2e0e0ead9
commit 43fe238c96
1 changed files with 6 additions and 5 deletions

View File

@ -650,18 +650,19 @@ class account_invoice(osv.osv):
return ok
def button_reset_taxes(self, cr, uid, ids, context=None):
if not context:
if context is None:
context = {}
ctx = context.copy()
ait_obj = self.pool.get('account.invoice.tax')
for id in ids:
cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,))
partner = self.browse(cr, uid, id, context=context).partner_id
partner = self.browse(cr, uid, id, context=ctx).partner_id
if partner.lang:
context.update({'lang': partner.lang})
for taxe in ait_obj.compute(cr, uid, id, context=context).values():
ctx.update({'lang': partner.lang})
for taxe in ait_obj.compute(cr, uid, id, context=ctx).values():
ait_obj.create(cr, uid, taxe)
# Update the stored value (fields.function), so we write to trigger recompute
self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context)
self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=ctx)
return True
def button_compute(self, cr, uid, ids, context=None, set_total=False):