[FIX] sale: product_id_change with different unit of measure

When changing the product of SO line if the uom_id is different,
the uom of the product must be changed and quantity ordered is set
to 1.0.

opw:692556
This commit is contained in:
Goffin Simon
2016-11-03 10:39:53 +01:00
parent a545eb3919
commit 5f0bbe797f
+3 -2
View File
@@ -744,13 +744,14 @@ class SaleOrderLine(models.Model):
vals = {}
domain = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
if not self.product_uom or (self.product_id.uom_id.category_id.id != self.product_uom.category_id.id):
if not self.product_uom or (self.product_id.uom_id.id != self.product_uom.id):
vals['product_uom'] = self.product_id.uom_id
vals['product_uom_qty'] = 1.0
product = self.product_id.with_context(
lang=self.order_id.partner_id.lang,
partner=self.order_id.partner_id.id,
quantity=self.product_uom_qty,
quantity=vals.get('product_uom_qty') or self.product_uom_qty,
date=self.order_id.date_order,
pricelist=self.order_id.pricelist_id.id,
uom=self.product_uom.id