From 2f2c1057b3e395cbba41366bd6081ce020b1310c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 23 Jan 2014 17:15:23 +0100 Subject: [PATCH] [FIX] read: fix performance issue due to O(n)^2 sorting bzr revid: fva@openerp.com-20140123161523-xvc8so45uwj3uivs --- addons/web/controllers/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 7be957bf4e2..f847f7734b0 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1084,7 +1084,12 @@ class DataSet(openerpweb.Controller): } records = Model.read(ids, fields or False, req.context) - records.sort(key=lambda obj: ids.index(obj['id'])) + + index = {} + for r in records: + index[r['id']] = r + records = [index[x] for x in ids if x in index] + return { 'length': length, 'records': records