[FIX]purchase_requisition: Creating requistions from OP

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

closes odoo/odoo#28611
This commit is contained in:
Goffin Simon
2018-11-13 15:08:20 +00:00
parent da2d415b79
commit 6123cc912c
@@ -337,3 +337,14 @@ class ProcurementRule(models.Model):
values['picking_type_id'] = self.picking_type_id.id
self.env['purchase.requisition'].create(values)
return True
class Orderpoint(models.Model):
_inherit = "stock.warehouse.orderpoint"
def _quantity_in_progress(self):
res = super(Orderpoint, self)._quantity_in_progress()
for op in self:
for pr in self.env['purchase.requisition'].search([('state','=','draft'),('origin','=',op.name)]):
for prline in pr.line_ids.filtered(lambda l: l.product_id.id == op.product_id.id):
res[op.id] += prline.product_uom_id._compute_quantity(prline.product_qty, op.product_uom, round=False)
return res