[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) <whe@odoo.com>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user