From edb87e7d2200409af31bf09de12cdc3da0abfe2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 27 Oct 2024 19:43:15 +0100 Subject: [PATCH] Do not allow to add product or unit with amendment if there was no unit Invoice lines may already exist with incompatible unit which will fail to compute invoiced quantity. (grafted from a261281e016c9445639fd7a47fdf41b8bbb4ab8b) --HG-- branch : 6.0 --- modules/purchase_amendment/purchase.py | 8 ++++---- modules/sale_amendment/sale.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/purchase_amendment/purchase.py b/modules/purchase_amendment/purchase.py index af105586d2..2ede5ae9d8 100644 --- a/modules/purchase_amendment/purchase.py +++ b/modules/purchase_amendment/purchase.py @@ -237,12 +237,12 @@ class AmendmentLine(ModelSQL, ModelView): If(Eval('state') == 'draft', ('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', }, depends=['action', 'state', 'product_uom_category']) diff --git a/modules/sale_amendment/sale.py b/modules/sale_amendment/sale.py index 93baa1113e..560cc8d200 100644 --- a/modules/sale_amendment/sale.py +++ b/modules/sale_amendment/sale.py @@ -272,12 +272,12 @@ class AmendmentLine(ModelSQL, ModelView): If(Eval('state') == 'draft', ('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', }, depends=['action', 'state', 'product_uom_category'])