From 269a6ee128247d36c391df85cae9d7ade123ed7d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 11 Jul 2014 14:07:05 +0200 Subject: [PATCH] [FIX] filtering out of records which shouldn't be fetched/prefetched A todo would only filter out records selectioned by the same field's caching, it should filter out on the whole prefetching selection or an other field could/would just add it back to the set of records to fetch (and lead to Bad Things). Note: this probably deserves a test somehow, but I'm not quite sure how the todos thing works so... --- openerp/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index 73b0981f513..f48aa5bc14a 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -3177,10 +3177,12 @@ class BaseModel(object): } empty = self.browse() - records = self.browse(set(itertools.chain.from_iterable( - (self._in_cache_without(field) - self.env.todo.get(field, empty)).ids - for field in (self._fields[name] for name in field_names) - ))) + prefetch = set() + todo = set() + for field in (self._fields[name] for name in field_names): + prefetch.update(self._in_cache_without(field).ids) + todo.update(self.env.todo.get(field, empty).ids) + records = self.browse(prefetch - todo) result = [] for sub_ids in cr.split_for_in_conditions(records.ids):