diff --git a/modules/purchase_amendment/purchase.py b/modules/purchase_amendment/purchase.py index 900f04e7ff..7bfc70cca7 100644 --- a/modules/purchase_amendment/purchase.py +++ b/modules/purchase_amendment/purchase.py @@ -246,12 +246,12 @@ class AmendmentLine(ModelSQL, ModelView): & ~(Eval('quantity', 0) < 0), ('purchasable', '=', True), ()), - If(Eval('product_uom_category'), - ('default_uom_category', '=', Eval('product_uom_category')), - ()), + ('default_uom_category', '=', Eval('product_uom_category', -1)), ], states={ - 'readonly': Eval('state') != 'draft', + 'readonly': ( + (Eval('state') != 'draft') + | ~Eval('product_uom_category', None)), 'invisible': Eval('action') != 'line', }) product_supplier = fields.Many2One( @@ -310,9 +310,7 @@ class AmendmentLine(ModelSQL, ModelView): cls.__access__.add('amendment') unit_categories = cls._unit_categories() cls.unit.domain = [ - If(Bool(Eval('product_uom_category')), - ('category', 'in', [Eval(c) for c in unit_categories]), - ('category', '!=', -1)), + ('category', 'in', [Eval(c, -1) for c in unit_categories]), ] @classmethod diff --git a/modules/sale_amendment/sale.py b/modules/sale_amendment/sale.py index 52e06ee119..0070667998 100644 --- a/modules/sale_amendment/sale.py +++ b/modules/sale_amendment/sale.py @@ -284,12 +284,12 @@ class AmendmentLine(ModelSQL, ModelView): & ~(Eval('quantity', 0) < 0), ('salable', '=', True), ()), - If(Eval('product_uom_category'), - ('default_uom_category', '=', Eval('product_uom_category')), - ()), + ('default_uom_category', '=', Eval('product_uom_category', -1)), ], states={ - 'readonly': Eval('state') != 'draft', + 'readonly': ( + (Eval('state') != 'draft') + | ~Eval('product_uom_category', None)), 'invisible': Eval('action') != 'line', }) quantity = fields.Float( @@ -330,9 +330,7 @@ class AmendmentLine(ModelSQL, ModelView): cls.__access__.add('amendment') unit_categories = cls._unit_categories() cls.unit.domain = [ - If(Bool(Eval('product_uom_category')), - ('category', 'in', [Eval(c) for c in unit_categories]), - ('category', '!=', -1)), + ('category', 'in', [Eval(c, -1) for c in unit_categories]), ] @classmethod