[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
This commit is contained in:
Alexis de Lattre
2024-07-19 17:18:50 +02:00
parent e0b5c757b8
commit b497dcc1d2

View File

@@ -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: