Browse files

[FIX] models: make prefetching more specific in read()

Commit a07a076 restricts the prefetching to
`self` when accessing the fields to return.  This is too restrictive, as it
cancels prefetching of secondary records in computed fields.  In this commit we
limit the scope of the restriction to `self`'s model only; this fixes the
original issue without impacting other models.
  • Loading branch information...
rco-odoo committed Jan 11, 2019
1 parent 5f12e24 commit 3bdf4e6a0c10de6dc6fdc8fca3c0c20bbb78005d
Showing with 4 additions and 2 deletions.
  1. +4 −2 odoo/
@@ -3019,14 +3019,16 @@ def read(self, fields=None, load='_classic_read'):

# retrieve results from records; this takes values from the cache and
# computes remaining fields
self = self.with_prefetch(self._prefetch.copy())
data = {record: {'id':} for record in self}
missing = set()
use_name_get = (load == '_classic_read')
for name in (stored + inherited + computed):
convert = self._fields[name].convert_to_read
# read every field with prefetching limited to self; this avoids
# restrict the prefetching of self's model to self; this avoids
# computing fields on a larger recordset than self
for record in self.with_prefetch():
self._prefetch[self._name] = set(self._ids)
for record in self:
data[record][name] = convert(record[name], record, use_name_get)
except MissingError:

0 comments on commit 3bdf4e6

Please sign in to comment.