[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>
This commit is contained in:
Simon Lejeune
2019-09-06 09:34:58 +00:00
parent 707882497b
commit af2fd0aea3
2 changed files with 2 additions and 16 deletions
+1 -15
View File
@@ -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 """
+1 -1
View File
@@ -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>