Files
stock-logistics-warehouse/stock_reserve_rule/models/stock_location.py
Guewen Baconnier 4ae12c21ce Fix application of removal rules too broad
Example of configuration:

Rule location: Stock
Removal rule 1: Stock/Zone1
Removal rule 2: Stock/Zone2

Reservation of a stock move with Stock/Zone2 as source location.

Previously, it would reserve in Stock/Zone1.
Now, it will never be allowed to reserve in Stock/Zone1.

A warning message was added previously to warn the user about potential
issues, which is now obsolete so I removed it.
2021-08-11 11:55:48 +02:00

15 lines
545 B
Python

# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockLocation(models.Model):
_inherit = "stock.location"
def is_sublocation_of(self, others):
"""Return True if self is a sublocation of at least one other"""
self.ensure_one()
# Efficient way to verify that the current location is
# below one of the other location without using SQL.
return any(self.parent_path.startswith(other.parent_path) for other in others)