From e4901deafc05a35b5aef6eb60f2a2853f59a10bd Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Sun, 16 Jun 2024 23:54:28 +0200 Subject: [PATCH] stock_location_zone: fix kind allow view locations in location structure --- stock_location_zone/__manifest__.py | 2 +- stock_location_zone/models/stock_location.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/stock_location_zone/__manifest__.py b/stock_location_zone/__manifest__.py index 7935b0fce..3afc886eb 100644 --- a/stock_location_zone/__manifest__.py +++ b/stock_location_zone/__manifest__.py @@ -1,5 +1,5 @@ # Copyright 2017 Syvain Van Hoof (Okia sprl) -# Copyright 2016-2019 Jacques-Etienne Baudoux (BCIM) +# Copyright 2016 Jacques-Etienne Baudoux (BCIM) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { diff --git a/stock_location_zone/models/stock_location.py b/stock_location_zone/models/stock_location.py index 86a05ce9b..fa4b73170 100644 --- a/stock_location_zone/models/stock_location.py +++ b/stock_location_zone/models/stock_location.py @@ -1,5 +1,5 @@ # Copyright 2017 Sylvain Van Hoof -# Copyright 2018-2019 Jacques-Etienne Baudoux (BCIM sprl) +# Copyright 2018 Jacques-Etienne Baudoux (BCIM) # Copyright 2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -81,13 +81,17 @@ class StockLocation(models.Model): ) def _compute_location_kind(self): for location in self: - if location.zone_location_id and not location.area_location_id: + if location == location.zone_location_id: location.location_kind = "zone" continue parent = location.location_id - if location.usage == "internal" and parent.usage == "view": + if ( # Internal locations whose parent is view are main stocks + location.usage in ("internal", "view") + and not location.zone_location_id + and parent.usage == "view" + ): location.location_kind = "stock" elif ( # Internal locations having a zone and no children are bins @@ -98,12 +102,12 @@ class StockLocation(models.Model): ): location.location_kind = "bin" elif ( - location.usage == "internal" + # Internal locations having a zone and children are areas + location.usage in ("internal", "view") and location.zone_location_id and location.area_location_id and location.child_ids ): - # Internal locations having a zone and children are areas location.location_kind = "area" else: # All the rest are other locations