From b53ff53cdb31a382db8ecacebde295d44b8a72a2 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 19 Nov 2015 10:01:38 +0100 Subject: [PATCH] [FIX] purchase: do not create stock move for services If a PO containing services contains at least one stockable/consumable product, stock moves are generated for these services, which is not correct. --- addons/purchase/purchase.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 0a757923616..acb5a675bce 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -326,11 +326,10 @@ class PurchaseOrder(models.Model): @api.multi def _create_picking(self): for order in self: - ptypes = order.order_line.mapped('product_id.type') - if ('product' in ptypes) or ('consu' in ptypes): + if any([ptype in ['product', 'consu'] for ptype in order.order_line.mapped('product_id.type')]): res = order._prepare_picking() picking = self.env['stock.picking'].create(res) - moves = order.order_line._create_stock_moves(picking) + moves = order.order_line.filtered(lambda r: r.product_id.type in ['product', 'consu'])._create_stock_moves(picking) moves.action_confirm() moves.force_assign() return True