From 223485ff5ee1cd22cf2d2cbb62f25d24b5cd154d Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Mon, 30 Jan 2023 16:07:37 +0000 Subject: [PATCH] [FIX] stock: wrong UserError in intertransit Usecase to reproduce: Create a replenishment of warehouses sheme. E.g: Production WH -> Distribution WH -> Shops Set all the rules from SHOP to PRODUCTION as replenish on order. Go to the replenishment report. Usererror due to a loop in the rules. It's wrong because he found twice the same rule that pull from interwarehouse transit. Fix the code to handle intertransit rules closes odoo/odoo#112325 X-original-commit: ca8e7aedcb466a301f721579ece85749ce4b060b Signed-off-by: William Henrotin (whe) --- addons/stock/models/product.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 54857bb6b47..01df7c84f33 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -570,9 +570,12 @@ class Product(models.Model): def _get_rules_from_location(self, location, route_ids=False, seen_rules=False): if not seen_rules: seen_rules = self.env['stock.rule'] + warehouse = location.warehouse_id + if not warehouse and seen_rules: + warehouse = seen_rules[-1].propagate_warehouse_id rule = self.env['procurement.group']._get_rule(self, location, { 'route_ids': route_ids, - 'warehouse_id': location.warehouse_id + 'warehouse_id': warehouse, }) if rule in seen_rules: raise UserError(_("Invalid rule's configuration, the following rule causes an endless loop: %s", rule.display_name))