[FIX] sale, sale_stock: Changing the product uom

When changing the product in a SO line, the uom must be change if
the uom category of the product is different of the uom set.

Closes #11241

opw:671367
This commit is contained in:
Goffin Simon
2016-03-10 10:59:19 +01:00
parent 07dd720cf6
commit 03c84f2c76
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -728,7 +728,7 @@ class SaleOrderLine(models.Model):
vals = {}
domain = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
if not (self.product_uom and (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.category_id.id != self.product_uom.category_id.id):
vals['product_uom'] = self.product_id.uom_id
product = self.product_id.with_context(
+7 -1
View File
@@ -130,7 +130,13 @@ class SaleOrderLine(models.Model):
return self._check_package()
return {}
@api.onchange('product_id', 'product_uom_qty', 'product_uom', 'route_id')
@api.onchange('product_id')
def _onchange_product_id_uom_check_availability(self):
if not self.product_uom or (self.product_id.uom_id.category_id.id != self.product_uom.category_id.id):
self.product_uom = self.product_id.uom_id
self._onchange_product_id_check_availability()
@api.onchange('product_uom_qty', 'product_uom', 'route_id')
def _onchange_product_id_check_availability(self):
if not self.product_id or not self.product_uom_qty or not self.product_uom:
self.product_packaging = False