[FIX] purchase: uom for PO without product_id

When a purchase order line doesn't have a product_id, the current onchange
method would return False as uom_id since b675ff1, thus introducing an issue
since uom_id is required and the field may be not shown (so not changeable).

closes #7770
opw-646088
This commit is contained in:
Nicolas Lempereur 2015-07-28 14:57:05 +02:00
parent 5792e4063b
commit c1cb489ebe
1 changed files with 3 additions and 0 deletions

View File

@ -1113,6 +1113,9 @@ class purchase_order_line(osv.osv):
res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'product_uom' : uom_id or False}}
if not product_id:
if not uom_id:
uom_id = self.default_get(cr, uid, ['product_uom'], context=context).get('product_uom', False)
res['value']['product_uom'] = uom_id
return res
product_product = self.pool.get('product.product')