From f1900a72daa768e259e2236767f0e6e6087f37a1 Mon Sep 17 00:00:00 2001 From: David Blanco Bautista Date: Wed, 6 Oct 2021 00:50:19 +0200 Subject: [PATCH] Validate product-boms relation when changing product of bom output issue10776 review355541002 --- bom.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bom.py b/bom.py index 5c816b8e92..f2294d4574 100644 --- a/bom.py +++ b/bom.py @@ -132,6 +132,20 @@ class BOMOutput(BOMInput): # Validate that output_products domain on bom is still valid ProductBOM._validate(bom_products, ['bom']) + @classmethod + def write(cls, *args): + pool = Pool() + ProductBOM = pool.get('product.product-production.bom') + actions = iter(args) + bom_products = [] + for outputs, values in zip(actions, actions): + if 'product' in values: + bom_products.extend( + [b for o in outputs for b in o.product.boms]) + super().write(*args) + # Validate that output_products domain on bom is still valid + ProductBOM._validate(bom_products, ['bom']) + class BOMTree(ModelView): 'BOM Tree'