summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-08-10 16:17:28 +0200
committerChristophe Simonis <chs@odoo.com>2017-08-10 16:17:28 +0200
commitdde62073baf5a0cc45678e4504fe2f54ccffcf18 (patch)
treea9db807928a2ae01488df77582efae3785658bf1 /odoo/models.py
parent3e54d9b56d1cb9b61c72b6990a6a313ef566101e (diff)
parenta2361e23ea95c308ac7576c614c0a1938707def0 (diff)
[MERGE] forward port branch saas-14 up to a2361e23ea9
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 4e76728ed8f..d6417b0b7cd 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -2555,10 +2555,6 @@ class BaseModel(object):
else:
records &= self._in_cache_without(f)
- # prefetch at most PREFETCH_MAX records
- if len(records) > PREFETCH_MAX:
- records = records[:PREFETCH_MAX] | self
-
# fetch records with read()
assert self in records and field in fs
records = records.with_prefetch(self._prefetch)
@@ -4683,13 +4679,16 @@ class BaseModel(object):
return RecordCache(self)
@api.model
- def _in_cache_without(self, field):
- """ Make sure ``self`` is present in cache (for prefetching), and return
- the records of model ``self`` in cache that have no value for ``field``
- (:class:`Field` instance).
+ def _in_cache_without(self, field, limit=PREFETCH_MAX):
+ """ Return records to prefetch that have no value in cache for ``field``
+ (:class:`Field` instance), including ``self``.
+ Return at most ``limit`` records.
"""
ids = filter(None, self._prefetch[self._name] - set(self.env.cache[field]))
- return self.browse(ids)
+ recs = self.browse(ids)
+ if limit and len(recs) > limit:
+ recs = self + (recs - self)[:(limit - len(self))]
+ return recs
@api.model
def refresh(self):