[IMP] stock.location: always return full name in name_get
bzr revid: rco@openerp.com-20120113151548-hyj48p274sbgj4vu
This commit is contained in:
parent
0a04e3640d
commit
aa84c454ad
|
@ -74,35 +74,22 @@ class stock_location(osv.osv):
|
|||
_order = 'parent_left'
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
res = []
|
||||
if context is None:
|
||||
context = {}
|
||||
if not len(ids):
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, ['name','location_id'], context=context)
|
||||
for record in reads:
|
||||
name = record['name']
|
||||
if context.get('full',False):
|
||||
if record['location_id']:
|
||||
name = record['location_id'][1] + ' / ' + name
|
||||
res.append((record['id'], name))
|
||||
else:
|
||||
res.append((record['id'], name))
|
||||
return res
|
||||
# always return the full hierarchical name
|
||||
res = self._complete_name(cr, uid, ids, 'complete_name', None, context=context)
|
||||
return res.items()
|
||||
|
||||
def _complete_name(self, cr, uid, ids, name, args, context=None):
|
||||
""" Forms complete name of location from parent location to child location.
|
||||
@return: Dictionary of values
|
||||
"""
|
||||
def _get_one_full_name(location, level=4):
|
||||
if location.location_id:
|
||||
parent_path = _get_one_full_name(location.location_id, level-1) + "/"
|
||||
else:
|
||||
parent_path = ''
|
||||
return parent_path + location.name
|
||||
res = {}
|
||||
for m in self.browse(cr, uid, ids, context=context):
|
||||
res[m.id] = _get_one_full_name(m)
|
||||
names = [m.name]
|
||||
parent = m.location_id
|
||||
while parent:
|
||||
names.append(parent.name)
|
||||
parent = parent.location_id
|
||||
res[m.id] = ' / '.join(reversed(names))
|
||||
return res
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue