From b8691100d14bcf4720b8ef7ebd2c6c9c889afd08 Mon Sep 17 00:00:00 2001 From: mreficent Date: Thu, 30 Aug 2018 15:30:03 +0200 Subject: [PATCH] [UPD] _action_procurement_create method has been improved --- sale_procurement_group_by_line/model/sale.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sale_procurement_group_by_line/model/sale.py b/sale_procurement_group_by_line/model/sale.py index abea1268454..42175f891e2 100644 --- a/sale_procurement_group_by_line/model/sale.py +++ b/sale_procurement_group_by_line/model/sale.py @@ -62,7 +62,8 @@ def _action_procurement_create(self): if line.state != 'sale' or not line.product_id._need_procurement(): continue qty = 0.0 - for proc in line.procurement_ids: + for proc in line.procurement_ids.filtered( + lambda r: r.state != 'cancel'): qty += proc.product_qty if float_compare(qty, line.product_uom_qty, precision_digits=precision) >= 0: @@ -85,7 +86,8 @@ def _action_procurement_create(self): vals = line._prepare_order_line_procurement( group_id=line.procurement_group_id.id) vals['product_qty'] = line.product_uom_qty - qty - new_proc = self.env["procurement.order"].create(vals) + new_proc = self.env["procurement.order"].with_context( + procurement_autorun_defer=True).create(vals) new_proc.message_post_with_view( 'mail.message_origin_link', values={'self': new_proc, 'origin': line.order_id},