From 71eebf25e540bcdf43b006dc760607f79b9371c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 5 Mar 2015 11:43:27 +0100 Subject: [PATCH] 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 --- trytond/model/modelstorage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py index 6e23b63bb9..e6d87d7297 100644 --- a/trytond/model/modelstorage.py +++ b/trytond/model/modelstorage.py @@ -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):