From 44bd29fc844cdb21b879144fda4dbb94c4afcd2c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 2 Jul 2018 10:46:35 +0200 Subject: [PATCH] [FIX] mrp: quantity_done with tracked products Steps to reproduce the bug: - Create 3 stockable products P1, P2, P3 - P1 is tracked by serial numbers - Create a BOM for P3 with one P1 and one P2 as components - Set the quantity on hand to 5 for P1 and P2 - Create a MO for P3, produce it and mark the MO as done - On the MO in the sheet "Consumed product", the quantity_done for P1 and P2 are equal to 1.0 - Change the tracking of P1 to "No tracking" Bug: - Check the sheet "Consumed product" on the MO and the quantity_done was equal to 0.0 instead of 1.0 opw:1856340 --- addons/mrp/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 8fb99e526e9..e5d79379607 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -117,7 +117,7 @@ class StockMove(models.Model): @api.depends('move_lot_ids', 'move_lot_ids.quantity_done', 'quantity_done_store') def _qty_done_compute(self): for move in self: - if move.has_tracking != 'none': + if move.has_tracking != 'none' or move.sudo().move_lot_ids.mapped('lot_id'): move.quantity_done = sum(move.move_lot_ids.filtered(lambda x: x.done_wo).mapped('quantity_done')) #TODO: change with active_move_lot_ids? else: move.quantity_done = move.quantity_done_store