From dea93a683b2d827d1cd26f754524cee0406e2d71 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 31 May 2019 13:09:03 +0000 Subject: [PATCH] [FIX] purchase: orderpoint on existing PO - Create product A: Reordering rule of 5 units Set a vendor V - Create a SO with 1 unit of A - Create a PO with 1 unit of A for vendor V - Run the scheduler => the PO contains 6 units - Run the scheduler => the PO contains 12 units The PO should not be updated the second time the scheduler is run. It occurs because the `orderpoint_id` is not set on the PO line, while the `_quantity_in_progress` method searches for PO lines with the orderpoint set. opw-2000962 closes odoo/odoo#33798 Signed-off-by: Nicolas Martinelli (nim) --- addons/purchase/models/purchase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index cf22d15e040..fbe45973e60 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -983,11 +983,15 @@ class ProcurementRule(models.Model): if price_unit and seller and line.order_id.currency_id and seller.currency_id != line.order_id.currency_id: price_unit = seller.currency_id.compute(price_unit, line.order_id.currency_id) - return { + res = { 'product_qty': line.product_qty + procurement_uom_po_qty, 'price_unit': price_unit, 'move_dest_ids': [(4, x.id) for x in values.get('move_dest_ids', [])] } + orderpoint_id = values.get('orderpoint_id') + if orderpoint_id: + res['orderpoint_id'] = orderpoint_id.id + return res @api.multi def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, values, po, supplier):