[FIX] purchase: warning uom category different only if the changed field is product_uom itself.

Changing product_id with a different unit category does not trigger the uom category change warning

bzr revid: dle@openerp.com-20131206121552-xre6jj34cpfuldoa
This commit is contained in:
Denis Ledoux 2013-12-06 13:15:52 +01:00
parent ac0e22bd6c
commit 847ca65a23
1 changed files with 4 additions and 1 deletions

View File

@ -908,8 +908,11 @@ class purchase_order_line(osv.osv):
"""
onchange handler of product_uom.
"""
if context is None:
context = {}
if not uom_id:
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'product_uom' : uom_id or False}}
context = dict(context, purchase_uom_check=True)
return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
name=name, price_unit=price_unit, context=context)
@ -983,7 +986,7 @@ class purchase_order_line(osv.osv):
uom_id = product_uom_po_id
if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id:
if self._check_product_uom_group(cr, uid, context=context):
if context.get('purchase_uom_check') and self._check_product_uom_group(cr, uid, context=context):
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_po_id