[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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user