[FIX] account: force uom from product category
When we change a product line of an account invoice, a current unit with a invalid unit category was not dropped which should be since: - it is different from a sale.order,, - there is a domain on the unit of measure only allowing units from the product's unit category. This fixes drop the current unit of mesure in this case. opw-640985
This commit is contained in:
parent
7def86fcc7
commit
c63230d0d0
|
@ -1486,6 +1486,7 @@ class account_invoice_line(osv.osv):
|
|||
else:
|
||||
return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}}
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
fpos_obj = self.pool.get('account.fiscal.position')
|
||||
fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id, context=context) or False
|
||||
|
||||
|
@ -1518,7 +1519,13 @@ class account_invoice_line(osv.osv):
|
|||
result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id})
|
||||
result['name'] = res.partner_ref
|
||||
|
||||
result['uos_id'] = uom_id or res.uom_id.id
|
||||
if uom_id:
|
||||
uom = product_uom_obj.browse(cr, uid, uom_id)
|
||||
if res.uom_id.category_id.id != uom.category_id.id:
|
||||
result['uos_id'] = res.uom_id.id
|
||||
else:
|
||||
result['uos_id'] = uom_id
|
||||
|
||||
if res.description:
|
||||
result['name'] += '\n'+res.description
|
||||
|
||||
|
|
Loading…
Reference in New Issue