diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index a9afc258004..e8a1344cb08 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -16,8 +16,13 @@ class StockQuantPackage(models.Model): @api.depends('quant_ids') def _compute_weight(self): weight = 0.0 - for quant in self.quant_ids: - weight += quant.quantity * quant.product_id.weight + if self.env.context.get('picking_id'): + current_picking_move_line_ids = self.env['stock.move.line'].search([('result_package_id', '=', self.id), ('picking_id', '=', self.env.context['picking_id'])]) + for ml in current_picking_move_line_ids: + weight += ml.product_uom_id._compute_quantity(ml.qty_done,ml.product_id.uom_id) * ml.product_id.weight + else: + for quant in self.quant_ids: + weight += quant.quantity * quant.product_id.weight self.weight = weight weight = fields.Float(compute='_compute_weight', help="Weight computed based on the sum of the weights of the products.")