From 2ea4cedc05840fb51e091aeec57a3ff315188510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 10 Oct 2014 10:04:13 +0200 Subject: [PATCH] Use on_change on default_uom instead of sale_uom Changing the value of sale_uom when it is changed, prevents the user to select an other value than the default one because when the user remove the current value it is set back to the default one. issue4237 review11561002 --- product.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/product.py b/product.py index 5bea2385b2..8cf9086119 100644 --- a/product.py +++ b/product.py @@ -52,15 +52,20 @@ class Template: return 0 @fields.depends('default_uom', 'sale_uom', 'salable') - def on_change_with_sale_uom(self): + def on_change_default_uom(self): + try: + changes = super(Template, self).on_change_default_uom() + except AttributeError: + changes = {} if self.default_uom: if self.sale_uom: if self.default_uom.category == self.sale_uom.category: - return self.sale_uom.id + changes['sale_uom'] = self.sale_uom.id else: - return self.default_uom.id + changes['sale_uom'] = self.default_uom.id else: - return self.default_uom.id + changes['sale_uom'] = self.default_uom.id + return changes class Product: