Fix result order of search_read

read doesn't respect the order of the given ids but search_read has an order
parameter so the read result must be sorted using the index of search result.

issue3228
review11051002
This commit is contained in:
Cédric Krier committed 2015-03-05 11:43:27 +01:00
1 parent 191ce31f1d
commit 71eebf25e5
1 file changed
+4 -1
+4 -1
View File
@@ -365,7 +365,10 @@ class ModelStorage(Model):
fields_names = cls._fields.keys()
if 'id' not in fields_names:
fields_names.append('id')
return cls.read(map(int, records), fields_names)
rows = cls.read(map(int, records), fields_names)
index = {r.id: i for i, r in enumerate(records)}
rows.sort(key=lambda r: index[r['id']])
return rows
@classmethod
def _search_domain_active(cls, domain, active_test=True):