From 659fb5d47e3b6d391870096374eaa7fe6aba9e4a Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 16 Nov 2016 11:54:29 +0100 Subject: [PATCH] [FIX] stock: fix location complete_name and name_get - complete_name field should show the entire hierarchy of locations. However currently it stops at first non view location. This commit fixes the complete_name computation. - name_get should correctly handle translations. It is now correctly computed instead of relying on stored value which could be incorrect depending on langages. Moreover name_get displays short name like old implementation of complete_name. --- addons/stock/models/stock_location.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 5763903b071..f71f82df366 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -25,7 +25,6 @@ class Location(models.Model): return res name = fields.Char('Location Name', required=True, translate=True) - # TDE CLEAME: unnecessary field, use name_get instead complete_name = fields.Char("Full Location Name", compute='_compute_complete_name', store=True) active = fields.Boolean('Active', default=True, help="By unchecking the active field, you may hide a location without deleting it.") usage = fields.Selection([ @@ -75,14 +74,22 @@ class Location(models.Model): """ Forms complete name of location from parent location to child location. """ name = self.name current = self - while current.location_id and current.usage != 'view': + while current.location_id: current = current.location_id name = '%s/%s' % (current.name, name) self.complete_name = name @api.multi def name_get(self): - return [(location.id, location.complete_name) for location in 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 + name = location.name + "/" + name + ret_list.append((orig_location.id, name)) + return ret_list def get_putaway_strategy(self, product): ''' Returns the location where the product has to be put, if any compliant putaway strategy is found. Otherwise returns None.'''