From 1a125f765ecb1f5fa0a24b3ea4a16a5b576cbe3d Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Thu, 23 Nov 2017 15:04:15 +0100 Subject: [PATCH] [FIX] mrp: use reserved SN for quality steps. Use case to reproduce: - Create a BOM with a component product tracked by SN - Create a MO for this product and reserve it. - Plan WO and process it. - Register the same lot than the reserved one. -> Error message: you can't use twice the same serial number It happens because WO use temporary move line that should not be considered as a real object. However it exists is a constraint that trigger if two move lines share the same SN for the same product. It's a wanted behavior that a real move line share the same SN that temporary move lines. This commit prevent real and false move lines comparaison. --- addons/mrp/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index d97bfdb9310..863b863c42c 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -22,12 +22,12 @@ class StockMoveLine(models.Model): if self.move_id.production_id: finished_moves = self.move_id.production_id.move_finished_ids finished_move_lines = finished_moves.mapped('move_line_ids') - lines |= finished_move_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name)) + lines |= finished_move_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name) and ml.done_wo == self.done_wo) if self.move_id.raw_material_production_id: raw_moves = self.move_id.raw_material_production_id.move_raw_ids raw_moves_lines = raw_moves.mapped('move_line_ids') raw_moves_lines |= self.move_id.active_move_line_ids - lines |= raw_moves_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name)) + lines |= raw_moves_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name) and ml.done_wo == self.done_wo) return lines @api.multi