stock.location name_get results in 6.1 always ordered on id instead of on parent_left (value of _order)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Confirmed
|
Low
|
OpenERP R&D Addons Team 2 |
Bug Description
There is a regression in the stock module of 6.1 (addons revno 6947). The name_get logic of the model stock.location in the has changed as compared to 6.0 but now always returns the names in order of the id of the stock location. This is because the the _complete_name method (used in name_get) returns a dictionary and a dictionary is unordered, but Python will put it in the order of the key (the id).
The problem becomes apparent when you create a view on an object that is linked to stock location (like stock.inventory) with a field with the selection widget on the stock location_id like so:
<field name="location_id" widget="selection" />
The list of values to choose from proffered by the system will be in the order of the id of the stock location instead of the expected order on the value of parent_left (this is the order specified with the _order attribute on stock.location).
Changing the original code:
def name_get(self, cr, uid, ids, context=None):
# always return the full hierarchical name
res = self._complete_
return res.items()
def _complete_
""" Forms complete name of location from parent location to child location.
@return: Dictionary of values
"""
res = {}
for m in self.browse(cr, uid, ids, context=context):
names = [m.name]
parent = m.location_id
while parent:
return res
by
def name_get(self, cr, uid, ids, context=None):
# always return the full hierarchical name
res = self._complete_
return res
def _complete_
""" Forms complete name of location from parent location to child location.
@return: Dictionary of values
"""
res = []
for m in self.browse(cr, uid, ids, context=context):
names = [m.name]
parent = m.location_id
while parent:
return res
solves the problem.
Changed in openobject-addons: | |
assignee: | nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2) |
importance: | Undecided → Low |
status: | New → Confirmed |