diff options
| author | Simon Lejeune <sle@openerp.com> | 2019-09-05 13:34:32 +0000 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2019-09-06 09:34:58 +0000 |
| commit | af2fd0aea310895e3d021c171684dfa7b80c7cd0 (patch) | |
| tree | 781e363118a7d354068ff97fc064e53ccfc3b806 /addons | |
| parent | 707882497b397ce908c49fe0b9ed0e1911f3e6a4 (diff) | |
[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) <sle@openerp.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/stock/models/stock_location.py | 16 | ||||
| -rw-r--r-- | 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 @@ <field name="arch" type="xml"> <tree string="Stock Location" decoration-info="usage=='view'" decoration-danger="usage=='internal'" create="false"> <field name="active" invisible="1"/> - <field name="display_name" string="Location"/> + <field name="complete_name" string="Location"/> <field name="usage"/> <field name="company_id" groups="base.group_multi_company"/> </tree> |
