diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-08-10 16:22:36 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-08-10 16:22:36 +0200 |
| commit | 85571bb78c9acc4e867cc3b480be9236a756fc22 (patch) | |
| tree | 11e77c15caeeb6cb01e09835892bc75351e0c6ba /odoo/models.py | |
| parent | deba788b4cdc22bb50e0c19adb5ed35ed33c0a01 (diff) | |
| parent | dde62073baf5a0cc45678e4504fe2f54ccffcf18 (diff) | |
[MERGE] forward port branch saas-15 up to dde62073baf
Diffstat (limited to 'odoo/models.py')
| -rw-r--r-- | odoo/models.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/odoo/models.py b/odoo/models.py index 6949a5b9d45..bff10e28b38 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -2554,10 +2554,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) @@ -4682,13 +4678,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): |
