From 08dfda9ec677d11556d3a218cb04af6f799646a0 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 29 Jan 2014 17:32:38 +0100 Subject: [PATCH] [FIX] purchase: on po confirm, avoid to write location_id on the chained stock move if the move is done On purchase order confirmation, if the order_line comes from a procurement order created by a sale order, it tried to write on the location_id, whatever the move state was, even done. Or, sometimes, the stock move associated to the procurement order (from the so) was already done, for example because we forced the availability of the stock move. It makes sense to not write the location_id if the move is already done, because the location_id is already good. bzr revid: dle@openerp.com-20140129163238-1s1t9oc814z4z7f3 --- addons/purchase/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 1cee51eb8dd..8102ef6b469 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -693,7 +693,7 @@ class purchase_order(osv.osv): continue if order_line.product_id.type in ('product', 'consu'): move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context=context)) - if order_line.move_dest_id: + if order_line.move_dest_id and order_line.move_dest_id.state != 'done': order_line.move_dest_id.write({'location_id': order.location_id.id}) todo_moves.append(move) stock_move.action_confirm(cr, uid, todo_moves)