From 310e3dadd0c4e95f94528774896371ff326877d8 Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Thu, 3 Aug 2017 16:01:07 +0200 Subject: [PATCH] [FIX] delivery: adapt weight computation to new stock --- addons/delivery/models/stock_picking.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index 2db6263a627..32d9d760234 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -13,9 +13,10 @@ class StockQuantPackage(models.Model): @api.one @api.depends('quant_ids') def _compute_weight(self): - weight = 0 - for quant in self.quant_ids: - weight += quant.qty * quant.product_id.weight + smls = self.env['stock.move.line'].search([('product_id', '!=', False), ('result_package_id', '=', self.id)]) + weight = 0.0 + for sml in smls: + weight += sml.product_uom_id._compute_quantity(sml.qty_done, sml.product_id.uom_id) * sml.product_id.weight self.weight = weight weight = fields.Float(compute='_compute_weight') @@ -70,7 +71,7 @@ class StockPicking(models.Model): weight = 0.0 for move_line in self.move_line_ids: if move_line.product_id and not move_line.result_package_id: - weight += move_line.product_uom_id._compute_quantity(move_line.product_qty, move_line.product_id.uom_id) * move_line.product_id.weight + weight += move_line.product_uom_id._compute_quantity(move_line.qty_done, move_line.product_id.uom_id) * move_line.product_id.weight self.weight_bulk = weight @api.one