diff --git a/stock_location_bin_name/models/stock_location.py b/stock_location_bin_name/models/stock_location.py index d746b765c..3fa503d79 100644 --- a/stock_location_bin_name/models/stock_location.py +++ b/stock_location_bin_name/models/stock_location.py @@ -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')