Skip to content
Snippets Groups Projects
Commit ca8e7aed authored by Arnold Moyaux's avatar Arnold Moyaux
Browse files

[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#109640

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 97f52bd4
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment