From 22f8660e2211fd84f84f530cfed29a594a228a02 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 11 Dec 2017 16:47:53 +0100 Subject: [PATCH] [FIX] stock: don't propagate cancel when chained move is done When you have e.g. an SO with a product MTO generating a manufacturing order, and you put the delivery order to done, before the MO is done, you can not cancel the MO anymore, because the cancel method checks if the move is not done (and raises an error). As the user stays blocked in this case, it is better to just not try to cancel the destination move by not propagating the cancel when the destination move is done. opw-786571 --- addons/stock/stock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index d95e34eca3b..45fe1e380d9 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2532,7 +2532,8 @@ class stock_move(osv.osv): else: if move.move_dest_id: if move.propagate: - self.action_cancel(cr, uid, [move.move_dest_id.id], context=context) + if move.move_dest_id.state not in ('done', 'cancel'): + self.action_cancel(cr, uid, [move.move_dest_id.id], context=context) elif move.move_dest_id.state == 'waiting': #If waiting, the chain will be broken and we are not sure if we can still wait for it (=> could take from stock instead) self.write(cr, uid, [move.move_dest_id.id], {'state': 'confirmed'}, context=context)