diff --git a/CHANGELOG b/CHANGELOG index 66f0520f4e..6f3ab2dc66 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add lost and found per supplier and customer location + Version 5.4.0 - 2019-11-04 * Bug fixes (see mercurial logs for details) diff --git a/stock.py b/stock.py index 4e2d7864d4..adf9223666 100644 --- a/stock.py +++ b/stock.py @@ -20,6 +20,12 @@ class Location(metaclass=PoolMeta): depends=['type'], help="The party invoiced when consignment stock is used.") + @classmethod + def __setup__(cls): + super().__setup__() + cls.lost_found_location.states['invisible'] &= ( + ~Eval('type').in_(['supplier', 'customer'])) + @classmethod def _parent_domain(cls): domain = super(Location, cls)._parent_domain() @@ -27,6 +33,18 @@ class Location(metaclass=PoolMeta): domain['storage'].append('customer') return domain + @property + def lost_found_used(self): + lost_found = super().lost_found_used + if not lost_found and not self.warehouse and self.type == 'storage': + location = self.parent + while location: + if location.type in {'supplier', 'storage'}: + lost_found = location.lost_found_location + break + location = location.parent + return lost_found + class LocationLeadTime(metaclass=PoolMeta): __name__ = 'stock.location.lead_time'