Skip to content

Commit

Permalink
[FIX]purchase_requisition: Creating requistions from OP
Browse files Browse the repository at this point in the history
Steps to reproduce the bug:

- Create a product : stockable + purchase : propose a call for tenders + reordering rule (qty min 0, max 0, multiple 1)
- Create a SO for that product.
- Run the scheduler once : a requistion is generated (Purchases > Purchase > Purchase Agreements), which is normal behavior
- Run the scheduler a second time

Bug:

A new requistion was generated for the same product, by the same reordering rule

opw:1892950
  • Loading branch information
simongoffin committed Nov 13, 2018
1 parent 8d77288 commit 29311db
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions addons/purchase_requisition/models/purchase_requisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ class ProcurementRule(models.Model):
def _run_buy(self, product_id, product_qty, product_uom, location_id, name, origin, values):
if product_id.purchase_requisition != 'tenders':
return super(ProcurementRule, self)._run_buy(product_id, product_qty, product_uom, location_id, name, origin, values)
values = self.env['purchase.requisition']._prepare_tender_values(product_id, product_qty, product_uom, location_id, name, origin, values)
values['picking_type_id'] = self.picking_type_id.id
self.env['purchase.requisition'].create(values)
existing_pr = self.env['purchase.requisition'].search([('origin', '=', origin), ('state', '=', 'draft')])
if not existing_pr:
values = self.env['purchase.requisition']._prepare_tender_values(product_id, product_qty, product_uom, location_id, name, origin, values)
values['picking_type_id'] = self.picking_type_id.id
self.env['purchase.requisition'].create(values)
return True

0 comments on commit 29311db

Please sign in to comment.