[FIX] api: do not prefetch new records.

New records (with a NewId) are not necessary in the cache, but should
not be prefetched.
This check has been omitted during optimisation in b0c08a6846.

opw-1843566
opw-1843636
opw-1843683
opw-1843548
opw-1843629
opw-1843657

Closes #24595
This commit is contained in:
Christophe Simonis
2018-05-07 18:58:27 +02:00
parent 55891b6f4e
commit 9d6ea8ef3e
+3
View File
@@ -4776,6 +4776,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
recs = self.browse(self._prefetch[self._name])
ids = [self.id]
for record_id in self.env.cache.get_missing_ids(recs - self, field):
if not record_id:
# Do not prefetch `NewId`
continue
ids.append(record_id)
if limit and limit <= len(ids):
break