From c2b3a0a2dcb2674e04fd10d095caecc1403cc898 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 : 7.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 75bb9f2f21..16a7597c8d 100644 --- a/modules/purchase_amendment/purchase.py +++ b/modules/purchase_amendment/purchase.py @@ -250,12 +250,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( diff --git a/modules/sale_amendment/sale.py b/modules/sale_amendment/sale.py index 5758527214..d126c5fbab 100644 --- a/modules/sale_amendment/sale.py +++ b/modules/sale_amendment/sale.py @@ -287,12 +287,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(