From 9ae0291ce24b2b8fde3d893654f8c8ebb48e8690 Mon Sep 17 00:00:00 2001 From: "David (dafr)" Date: Thu, 15 Feb 2024 13:34:59 +0100 Subject: [PATCH] [FIX] purchase_stock: no overwrite of orderpoint.route_id action_set_supplier doesn't have to overwrite the orderpoint.route_id if it already has one that fit the requirements (action = 'buy'). OPW-3746624 closes odoo/odoo#154495 X-original-commit: f52a17082a5507b283a0107118ef411d3be0b192 Signed-off-by: William Henrotin (whe) --- addons/purchase_stock/models/product.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase_stock/models/product.py b/addons/purchase_stock/models/product.py index 725b96f4646..3e0e4963205 100644 --- a/addons/purchase_stock/models/product.py +++ b/addons/purchase_stock/models/product.py @@ -126,7 +126,8 @@ class SupplierInfo(models.Model): orderpoint = self.env['stock.warehouse.orderpoint'].browse(orderpoint_id) if not orderpoint: return - orderpoint.route_id = self.env['stock.rule'].search([('action', '=', 'buy')], limit=1).route_id.id + if 'buy' not in orderpoint.route_id.rule_ids.mapped('action'): + orderpoint.route_id = self.env['stock.rule'].search([('action', '=', 'buy')], limit=1).route_id.id orderpoint.supplier_id = self supplier_min_qty = self.product_uom._compute_quantity(self.min_qty, orderpoint.product_id.uom_id) if orderpoint.qty_to_order < supplier_min_qty: