[IMP] Hr expense: improve code

bzr revid: mra@mra-laptop-20101217075757-z11iwokcy2ynjese
This commit is contained in:
XRG 2010-12-17 13:27:57 +05:30 committed by Mustufa Rangwala
parent 668bf1ea37
commit 37742e1379
1 changed files with 7 additions and 3 deletions

View File

@ -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