mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_location_zone: Optimize a little affectations
This commit is contained in:
@@ -51,21 +51,26 @@ class StockLocation(models.Model):
|
||||
"is_zone", "location_id.zone_location_id", "location_id.area_location_id"
|
||||
)
|
||||
def _compute_zone_location_id(self):
|
||||
self_browse = self.browse()
|
||||
self.update({"zone_location_id": self_browse, "area_location_id": self_browse})
|
||||
for location in self:
|
||||
location.zone_location_id = self.browse()
|
||||
location.area_location_id = self.browse()
|
||||
if location.is_zone:
|
||||
location.zone_location_id = location
|
||||
continue
|
||||
parent = location.location_id
|
||||
if parent.zone_location_id:
|
||||
location.zone_location_id = parent.zone_location_id
|
||||
# If we have more than one level of area in a zone,
|
||||
# the grouping is done by the first level
|
||||
if parent.area_location_id:
|
||||
location.area_location_id = parent.area_location_id
|
||||
area_location_id = parent.area_location_id
|
||||
else:
|
||||
location.area_location_id = location
|
||||
area_location_id = location
|
||||
location.update(
|
||||
{
|
||||
"zone_location_id": parent.zone_location_id,
|
||||
"area_location_id": area_location_id,
|
||||
}
|
||||
)
|
||||
|
||||
@api.depends(
|
||||
"usage",
|
||||
|
||||
Reference in New Issue
Block a user