From 37742e1379ca7c728c079b02f589f73b6ade596c Mon Sep 17 00:00:00 2001 From: XRG <> Date: Fri, 17 Dec 2010 13:27:57 +0530 Subject: [PATCH] [IMP] Hr expense: improve code bzr revid: mra@mra-laptop-20101217075757-z11iwokcy2ynjese --- addons/hr_expense/hr_expense.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 0d0670d0d9b..bc9c1cc36e4 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -241,14 +241,18 @@ class hr_expense_line(osv.osv): def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None): if context is None: - context = {} + ctx = {} + else: + # we only want to update it locally + ctx = context.copy() + res = {} if product_id: product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) res['name'] = product.name # Compute based on pricetype of employee company - context['currency_id'] = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).user_id.company_id.currency_id.id - amount_unit = product.price_get('standard_price', context)[product.id] + ctx['currency_id'] = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).user_id.company_id.currency_id.id + amount_unit = product.price_get('standard_price', ctx)[product.id] res['unit_amount'] = amount_unit if not uom_id: res['uom_id'] = product.uom_id.id