[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.
This commit is contained in:
committed by
Thibault Delavallée
parent
42aaa68d10
commit
659fb5d47e
@@ -25,7 +25,6 @@ class Location(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
name = fields.Char('Location Name', required=True, translate=True)
|
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)
|
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.")
|
active = fields.Boolean('Active', default=True, help="By unchecking the active field, you may hide a location without deleting it.")
|
||||||
usage = fields.Selection([
|
usage = fields.Selection([
|
||||||
@@ -75,14 +74,22 @@ class Location(models.Model):
|
|||||||
""" Forms complete name of location from parent location to child location. """
|
""" Forms complete name of location from parent location to child location. """
|
||||||
name = self.name
|
name = self.name
|
||||||
current = self
|
current = self
|
||||||
while current.location_id and current.usage != 'view':
|
while current.location_id:
|
||||||
current = current.location_id
|
current = current.location_id
|
||||||
name = '%s/%s' % (current.name, name)
|
name = '%s/%s' % (current.name, name)
|
||||||
self.complete_name = name
|
self.complete_name = name
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def name_get(self):
|
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):
|
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.'''
|
''' Returns the location where the product has to be put, if any compliant putaway strategy is found. Otherwise returns None.'''
|
||||||
|
|||||||
Reference in New Issue
Block a user