From ce597129ecedeebb80262533a50985b4b5513ffc Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 30 Sep 2024 17:57:00 +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/README.rst | 6 ++++++ intrastat_product/models/intrastat_product_declaration.py | 7 ++++++- intrastat_product/readme/INSTALL.md | 2 ++ intrastat_product/static/description/index.html | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/intrastat_product/README.rst b/intrastat_product/README.rst index c8fca19..1d49c74 100644 --- a/intrastat_product/README.rst +++ b/intrastat_product/README.rst @@ -53,6 +53,12 @@ Installation This module is NOT compatible with the *account_intrastat* module from Odoo Enterprise. +We recommended to install the module **product_net_weight** from +``OCA/product-attribute ``\ \_. +If this module is installed, Odoo will use the *Net Weight* field of the +product to compute the intrastat declaration instead of the native +*Weight* field. + Configuration ============= diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index 70925a1..b53c7a0 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -363,7 +363,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: diff --git a/intrastat_product/readme/INSTALL.md b/intrastat_product/readme/INSTALL.md index 2227115..7a0d5e2 100644 --- a/intrastat_product/readme/INSTALL.md +++ b/intrastat_product/readme/INSTALL.md @@ -1,2 +1,4 @@ This module is NOT compatible with the *account_intrastat* module from Odoo Enterprise. + +We recommended to install the module **product_net_weight** from `OCA/product-attribute `_. If this module is installed, Odoo will use the *Net Weight* field of the product to compute the intrastat declaration instead of the native *Weight* field. diff --git a/intrastat_product/static/description/index.html b/intrastat_product/static/description/index.html index 14b9312..4d1ee95 100644 --- a/intrastat_product/static/description/index.html +++ b/intrastat_product/static/description/index.html @@ -402,6 +402,11 @@ those countries.

Installation

This module is NOT compatible with the account_intrastat module from Odoo Enterprise.

+

We recommended to install the module product_net_weight from +OCA/product-attribute <https://github.com/OCA/product-attribute>_. +If this module is installed, Odoo will use the Net Weight field of the +product to compute the intrastat declaration instead of the native +Weight field.