From 9d6ea8ef3e22d29181a0094807bf2b1745c36ef8 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 7 May 2018 18:58:27 +0200 Subject: [PATCH] [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 b0c08a684683e4247b6b78160f37524d16acd48f. opw-1843566 opw-1843636 opw-1843683 opw-1843548 opw-1843629 opw-1843657 Closes #24595 --- odoo/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odoo/models.py b/odoo/models.py index 5f9fc8c267b..1b0207e9eb9 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -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