From 399adb0834080cc14ab8c6715ce31050406342bb Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Wed, 12 Jul 2023 15:01:34 +0200 Subject: [PATCH] [FIX] product_total_weight_from_packaging. Uses weight in place of max_weight The max_weight is a concept that was introduced in odoo delivery module to define the transporter weight limit for the shipped packaging. Before v16, the transporter packaging and product packaging was the same model product.packaging. Now the transporter packaging is moved to the model stock.package.type. In v13, max_weight defined in delivery module on product.packaging was used also for product packaging dimension. In v14, the weight field was added on the product.packaging and the max_weight was still coming from delivery module. This was introducing inconsistency as some modules migrated from v13 to v14 still rely on max_weight and some rely on the new weight field. In v16, we have to drop this max_weight on product.packaging as the delivery module moved it to stock.package.type and we should rely only on the weight field. The migration of the product_packaging_dimension #1161 has to be fixed to not expose the old max_weight field and any data on max_weight must be moved to weight if empty. This module also deserves a big warning that it is lacking the weight uom conversions as it depends on product_packaging_dimension that depends on product_logistics_uom that allows to set a uom on the weight. The sum in this module is assuming all weights are in kg Co-authored-by: Jacques-Etienne Baudoux --- product_total_weight_from_packaging/models/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product_total_weight_from_packaging/models/product.py b/product_total_weight_from_packaging/models/product.py index 9799ca3cfc2..81a445faa17 100644 --- a/product_total_weight_from_packaging/models/product.py +++ b/product_total_weight_from_packaging/models/product.py @@ -11,7 +11,7 @@ def get_total_weight_from_packaging(self, qty): self.ensure_one() qty_by_packaging_with_weight = self.with_context( **{ - "_packaging_filter": lambda p: p.max_weight, + "_packaging_filter": lambda p: p.weight, "_packaging_values_handler": self._prepare_qty_by_packaging_values_with_weight, # noqa } ).product_qty_by_packaging(qty) @@ -33,5 +33,5 @@ def _prepare_qty_by_packaging_values_with_weight( res["weight"] = self.weight else: packaging = self.env["product.packaging"].browse(packaging_tuple.id) - res["weight"] = packaging.max_weight + res["weight"] = packaging.weight return res