From b497dcc1d2db2ed12d43c35c808c330e56a90f6d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 19 Jul 2024 17:18:50 +0200 Subject: [PATCH] [IMP] intrastat_product: if module product_net_weight is installed, use it If the OCA module product_net_weight from https://github.com/OCA/product-attribute is installed, use the field net_weight added by this module instead of the native weight field --- intrastat_product/models/intrastat_product_declaration.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index c9d0919..068e024 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -380,7 +380,12 @@ class IntrastatProductDeclaration(models.Model): elif source_uom.category_id == product.uom_id.category_id: # We suppose that, on product.template, # the 'weight' field is per uom_id - weight = product.weight * source_uom._compute_quantity( + # Test if module product_net_weight from OCA/product-attribute is installed + if hasattr(product, "net_weight"): + product_weight = product.net_weight + else: + product_weight = product.weight + weight = product_weight * source_uom._compute_quantity( line_qty, product.uom_id ) else: