From 29110b6487d5ca4d75c4dcd69d6c2e86ea8ae9e3 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 17 Jan 2011 17:51:13 +0530 Subject: [PATCH] [FIX] hr_expense: hr_expense not working when Employee is not assigned user_id lp bug: https://launchpad.net/bugs/703902 fixed bzr revid: mra@mra-laptop-20110117122113-blnbg42tr0oxh5ny --- addons/hr_expense/hr_expense.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index e7fd63eadb4..b137b78a789 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -251,13 +251,17 @@ class hr_expense_line(osv.osv): product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) res['name'] = product.name # Compute based on pricetype of employee company - 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 + employee = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context) + if employee.user_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 + else: + res['unit_amount'] = product.standard_price if not uom_id: res['uom_id'] = product.uom_id.id return {'value': res} hr_expense_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file