From d5fd89df5d1764aeb0a7d50a49b6b0a2ceeed3af Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 4 Apr 2019 07:45:09 +0000 Subject: [PATCH] [IMP] delivery: better handle package shipping weight If the shipping weight is changed on a package, we want to update the shipping weight on the picking to be consistent. We also want to be able to set a shipping weight on a package that has no carrier packaging, as we'll use the default one set on the carrier. --- addons/delivery/models/stock_picking.py | 2 +- addons/delivery/wizard/choose_delivery_package.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index 85a2db8cf53..d006e7fd036 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -63,7 +63,7 @@ class StockPicking(models.Model): weight += move_line.product_uom_id._compute_quantity(move_line.qty_done, move_line.product_id.uom_id) * move_line.product_id.weight picking.weight_bulk = weight - @api.depends('package_ids', 'weight_bulk') + @api.depends('package_ids', 'package_ids.shipping_weight', 'weight_bulk') def _compute_shipping_weight(self): for picking in self: picking.shipping_weight = picking.weight_bulk + sum([pack.shipping_weight for pack in picking.package_ids]) diff --git a/addons/delivery/wizard/choose_delivery_package.py b/addons/delivery/wizard/choose_delivery_package.py index 8c54c7e130a..789e74e0d72 100644 --- a/addons/delivery/wizard/choose_delivery_package.py +++ b/addons/delivery/wizard/choose_delivery_package.py @@ -60,5 +60,5 @@ class ChooseDeliveryPackage(models.TransientModel): # write shipping weight and product_packaging on 'stock_quant_package' if needed if self.delivery_packaging_id: delivery_package.packaging_id = self.delivery_packaging_id - if self.shipping_weight: - delivery_package.shipping_weight = self.shipping_weight + if self.shipping_weight: + delivery_package.shipping_weight = self.shipping_weight