From 24eee9d7ba9a6084d78c942428b679ec782fc94d Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 23 Dec 2015 16:15:42 +0100 Subject: [PATCH] [FIX] purchase: confirm of purchase orders with kit boms When using phantom/kit boms, `action_confirm` on the move can lead to the move unlink, as new moves with the different parts of the product have been created. See `_action_explode` in `mrp/stock.py` The method `action_confirm` on `stock.move` returns the list of remaining moves. `force_assign` should therefore be performed on this new moves list, returned by `action_confirm`, rather than be performed on the moves list sent to `action_confirm` opw-660722 --- addons/purchase/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 560b8eaece1..63fad3f2921 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -337,7 +337,8 @@ class PurchaseOrder(models.Model): res = order._prepare_picking() picking = self.env['stock.picking'].create(res) moves = order.order_line.filtered(lambda r: r.product_id.type in ['product', 'consu'])._create_stock_moves(picking) - moves.action_confirm() + move_ids = moves.action_confirm() + moves = self.env['stock.move'].browse(move_ids) moves.force_assign() return True