[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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user