Skip to content
Snippets Groups Projects
Commit 71f9c08e authored by Josse Colpaert's avatar Josse Colpaert Committed by amoyaux
Browse files

[FIX] mrp: make sure the note is logged when you change done qties

The production_id on the stock move line is a helper field for work
orders and you can not assume it is always set correctly.  As
non-tracked stock moves create the stock move lines themselves it is not
set.

So, for logging notes, we check the 2 production order fields through
the moves.
parent 212110a1
No related branches found
No related tags found
No related merge requests found
......@@ -37,8 +37,9 @@ class StockMoveLine(models.Model):
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']})
if move_line.production_id and move_line.state == 'done' and any(field in vals for field in ('lot_id', 'location_id', 'qty_done')):
move_line._log_message(move_line.production_id, move_line, 'mrp.track_production_move_template', vals)
production = move_line.move_id.production_id or move_line.move_id.raw_material_production_id
if production and move_line.state == 'done' and any(field in vals for field in ('lot_id', 'location_id', 'qty_done')):
move_line._log_message(production, move_line, 'mrp.track_production_move_template', vals)
return super(StockMoveLine, self).write(vals)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment