From af2fd0aea310895e3d021c171684dfa7b80c7cd0 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 5 Sep 2019 13:34:32 +0000 Subject: [PATCH] [FIX] stock: allow to sort on location name stock.location have a _rec_name to complete_name and an override of name_get that do not use complete_name To allow sorting on the name in the webclient, we display complete_name in the view instead of display_name, we actually get rid of the name_get and use its implementation in _compute_complete_name. closes odoo/odoo#36516 Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_location.py | 16 +--------------- addons/stock/views/stock_location_views.xml | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 00c8a315d12..c5e08556a9b 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -69,9 +69,8 @@ class Location(models.Model): @api.depends('name', 'location_id.complete_name') def _compute_complete_name(self): - """ Forms complete name of location from parent location to child location. """ for location in self: - if location.location_id.complete_name: + if location.location_id and location.usage != 'view': location.complete_name = '%s/%s' % (location.location_id.complete_name, location.name) else: location.complete_name = location.name @@ -122,19 +121,6 @@ class Location(models.Model): super(Location, children_location - self).with_context({'do_not_check_quant': True}).write(values) return super(Location, self).write(values) - def name_get(self): - ret_list = [] - for location in self: - orig_location = location - name = location.name - while location.location_id and location.usage != 'view': - location = location.location_id - if not name: - raise UserError(_('You have to set a name for this location.')) - name = location.name + "/" + name - ret_list.append((orig_location.id, name)) - return ret_list - @api.model def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): """ search full name and barcode """ diff --git a/addons/stock/views/stock_location_views.xml b/addons/stock/views/stock_location_views.xml index 72670fcbb2c..5f8053dbd6d 100644 --- a/addons/stock/views/stock_location_views.xml +++ b/addons/stock/views/stock_location_views.xml @@ -88,7 +88,7 @@ - +