Skip to content

Commit

Permalink
[UPD] _action_procurement_create method has been improved
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Aug 30, 2018
1 parent bb680b5 commit b869110
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sale_procurement_group_by_line/model/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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},
Expand Down

0 comments on commit b869110

Please sign in to comment.