From b478264bded10e59ef4ff83997fe03757dcd9d75 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 16 Aug 2012 19:11:49 +0530 Subject: [PATCH] [IMP] hr_expense: made change in condition bzr revid: cha@tinyerp.com-20120816134149-wjumyv73z72sh6w5 --- addons/hr_expense/hr_expense.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index fca62261814..44ecef2ebba 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -290,15 +290,14 @@ class hr_expense_line(osv.osv): def onchange_uom(self, cr, uid, ids, product_id, uom_id, context=None): res = {'value':{}} - if not uom_id: + if not uom_id or not product_id: return res - if product_id: - product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) - if uom.category_id.id != product.uom_id.category_id.id: - res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} - uom_id = product.uom_id.id - res['value'].update({'uom_id': uom_id}) + product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) + if uom.category_id.id != product.uom_id.category_id.id: + res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} + uom_id = product.uom_id.id + res['value'].update({'uom_id': uom_id}) return res hr_expense_line()