[FIX] mrp: production chained to a done or cancelled move

Do not try to run `action_assign` on the next move if it is done or
cancelled. The issue is that `action_assign` will first unlink the
existing pack operations before creating new ones, and the system
forbids to unlink these ones.

To reproduce this issue:
1. Create a product, routes manufacturing and MTO
2. Create SO with that product
3. Go to DO and force assign then cancel the delivery
4. Go to Manufacturing order created and produce

opw 778897
This commit is contained in:
Simon Lejeune
2017-11-02 14:02:18 +01:00
parent e134dde867
commit 50a6f50df1
+1 -1
View File
@@ -293,7 +293,7 @@ class StockMove(models.Model):
self.env['stock.quant'].quants_move(quants, move, move.location_dest_id, lot_id = movelot.lot_id.id)
moves_to_unreserve |= move
# Next move in production order
if move.move_dest_id:
if move.move_dest_id and move.move_dest_id.state not in ('done', 'cancel'):
move.move_dest_id.action_assign()
moves_to_unreserve.quants_unreserve()
moves_todo.write({'state': 'done', 'date': fields.Datetime.now()})