Permalink
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 b24e1aed43bf511201f50c9c833796d859f1507d
Showing with 3 additions and 2 deletions.
  1. +3 −2 odoo/models.py
@@ -3024,9 +3024,10 @@ def read(self, fields=None, load='_classic_read'):
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:
try:
data[record][name] = convert(record[name], record, use_name_get)
except MissingError:

0 comments on commit b24e1ae

Please sign in to comment.