From 5774bd2c3241af1d425df3b46b36af97ffb9fdba Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Thu, 26 Oct 2023 22:52:55 +0200 Subject: [PATCH] Prevent changing party, template and product on product customer Closes #12607 --- modules/sale_product_customer/product.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/sale_product_customer/product.py b/modules/sale_product_customer/product.py index 230c0fae48..91f69c6b00 100644 --- a/modules/sale_product_customer/product.py +++ b/modules/sale_product_customer/product.py @@ -22,7 +22,10 @@ class ProductCustomer( ('products', '=', Eval('product')), ()), If(Eval('active'), ('active', '=', True), ()), - ]) + ], + states={ + 'readonly': Eval('id', -1) >= 0, + }) product = fields.Many2One( 'product.product', "Variant", domain=[ @@ -30,9 +33,15 @@ class ProductCustomer( ('template', '=', Eval('template')), ()), If(Eval('active'), ('active', '=', True), ()), - ]) - party = fields.Many2One('party.party', "Customer", required=True, - ondelete='CASCADE') + ], + states={ + 'readonly': Eval('id', -1) >= 0, + }) + party = fields.Many2One( + 'party.party', "Customer", required=True, ondelete='CASCADE', + states={ + 'readonly': Eval('id', -1) >= 0, + }) name = fields.Char("Name", translate=True) code = fields.Char("Code")