[FIX] Added context in invoice's compute_invoice_totals method

lp bug: https://launchpad.net/bugs/932825 fixed

bzr revid: rmu@tinyerp.com-20120710120316-xo1sk1u3fq3fqt9i
This commit is contained in:
Lorenzo Battistini
2012-07-10 17:33:16 +05:30
committed by Ravish Murari (OpenERP)
parent 147381810c
commit e6f10a71ba
+6 -3
View File
@@ -767,17 +767,20 @@ class account_invoice(osv.osv):
if not key in tax_key:
raise osv.except_osv(_('Warning !'), _('Taxes are missing!\nClick on compute button.'))
def compute_invoice_totals(self, cr, uid, inv, company_currency, ref, invoice_move_lines):
def compute_invoice_totals(self, cr, uid, inv, company_currency, ref, invoice_move_lines,context=None):
if context is None:
context={}
total = 0
total_currency = 0
cur_obj = self.pool.get('res.currency')
for i in invoice_move_lines:
if inv.currency_id.id != company_currency:
context.update({'date': inv.date_invoice or time.strftime('%Y-%m-%d')})
i['currency_id'] = inv.currency_id.id
i['amount_currency'] = i['price']
i['price'] = cur_obj.compute(cr, uid, inv.currency_id.id,
company_currency, i['price'],
context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')})
context=context)
else:
i['amount_currency'] = False
i['currency_id'] = False
@@ -887,7 +890,7 @@ class account_invoice(osv.osv):
# create one move line for the total and possibly adjust the other lines amount
total = 0
total_currency = 0
total, total_currency, iml = self.compute_invoice_totals(cr, uid, inv, company_currency, ref, iml)
total, total_currency, iml = self.compute_invoice_totals(cr, uid, inv, company_currency, ref, iml,context=ctx)
acc_id = inv.account_id.id
name = inv['name'] or '/'