mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Change the area field as a related field
It is not stored because we only need it for the generation of the name. It slows creation of locations for no value. If we need to search on it, we can use a search method.
This commit is contained in:
@@ -17,19 +17,14 @@ class StockLocation(models.Model):
|
||||
".{level:0>2}'")
|
||||
|
||||
area = fields.Char(
|
||||
'Area',
|
||||
compute='_compute_area',
|
||||
store=True,
|
||||
string='Area',
|
||||
# Field used for _onchange_attribute_compute_name, so we
|
||||
# have the name in the record's cache. Does not need to be
|
||||
# stored as we already have 'area_location_id'
|
||||
related='area_location_id.name',
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.depends('name', 'location_kind', 'location_id.area')
|
||||
def _compute_area(self):
|
||||
for location in self:
|
||||
if location.location_kind == 'area':
|
||||
location.area = location.name
|
||||
else:
|
||||
location.area = location.location_id.area
|
||||
|
||||
@api.multi
|
||||
@api.onchange('corridor', 'row', 'rack', 'level',
|
||||
'posx', 'posy', 'posz')
|
||||
|
||||
Reference in New Issue
Block a user