[FIX] mrp: workorder: use the reserved move lines

Rev [1] was intended to be applied when changing the lot of the produced
product on the manufacturing order, somewhere along the line the code
was also called when setting the lot_id on the work order. When used in
this context, it broke the reconciliation between the reserved move
lines and the temporary move lines because a lot_produced_id was wrongly
set.

We fix the issue by only applying the code on prod move. This is done by
checking if the move is a production one through the stock move, because
there we are able to differenciate the raw material and production move,
not on the move line where production_id is always set.

[1] 471115b06a

Fixes #20964
This commit is contained in:
Simon Lejeune
2017-11-17 13:32:04 +01:00
parent 179071bb50
commit 49c3f64369
+1 -1
View File
@@ -33,7 +33,7 @@ class StockMoveLine(models.Model):
@api.multi
def write(self, vals):
for move_line in self:
if move_line.production_id and 'lot_id' in vals:
if move_line.move_id.production_id and 'lot_id' in vals:
move_line.production_id.move_raw_ids.mapped('move_line_ids')\
.filtered(lambda r: r.done_wo and not r.done_move and r.lot_produced_id == move_line.lot_id)\
.write({'lot_produced_id': vals['lot_id']})