diff options
| author | Pierre Masereel <pim@odoo.com> | 2019-01-09 12:52:01 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2019-01-09 12:52:01 +0000 |
| commit | ad40ed029ce0cf7cafec4454b4e9ca3a8db33d55 (patch) | |
| tree | b43306631d4b943b9687950c308ab419188dba7e /addons/delivery/models/stock_picking.py | |
| parent | a323b86ecbcad3ede67d8d656655d40bcdc9e6e9 (diff) | |
[FIX] delivery: weight computation without quant
The weight computation was not working anymore on packages that don't
have any quant, because they are fresh ones.
We fix this by setting back the behaviour with the picking id in
context and adapt the function to find the corresponding move lines.
closes odoo/odoo#30071
Diffstat (limited to 'addons/delivery/models/stock_picking.py')
| -rw-r--r-- | addons/delivery/models/stock_picking.py | 9 |
1 files changed, 7 insertions, 2 deletions
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.") |
