From e97fbf2d6bb535487586dc157483692549ae6377 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Fri, 1 Dec 2017 15:59:34 +0100 Subject: [PATCH] [IMP] delivery: packaging type max weight limit When a max weight is set on a packaging type is set, you get a warning when you put in pack some content that weighs bigger than the max weight of the packaging type --- addons/delivery/wizard/choose_delivery_package.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/delivery/wizard/choose_delivery_package.py b/addons/delivery/wizard/choose_delivery_package.py index c0f87c80b38..ed10e8727aa 100644 --- a/addons/delivery/wizard/choose_delivery_package.py +++ b/addons/delivery/wizard/choose_delivery_package.py @@ -45,6 +45,15 @@ class ChooseDeliveryPackage(models.TransientModel): total_weight = sum([po.qty_done * po.product_id.weight for po in move_line_ids]) return total_weight + @api.onchange('delivery_packaging_id', 'shipping_weight') + def _onchange_packaging_weight(self): + if self.delivery_packaging_id.max_weight and self.shipping_weight > self.delivery_packaging_id.max_weight: + warning_mess = { + 'title': _('Package too heavy!'), + 'message': _('The weight of your package is higher than the maximum weight authorized for this package type. Please choose another package type.') + } + return {'warning': warning_mess} + def put_in_pack(self): picking_id = self.env['stock.picking'].browse(self.env.context['active_id']) if not self.stock_quant_package_id: