From 643be98fcf2ef3c9265e59dea3cba109b1874504 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 9 Jul 2014 15:08:29 +0200 Subject: [PATCH 1/2] [FIX] models: store FailedValue in cache on log_access fields, too This should fix an issue discovered by tde when reading all fields on a record on which you don't have access right: - _read_from_database() fetches result and store it in cache - read() retrieves values from cache, starting with field 'create_date'... - ... which is not in cache, so prefetch that field, read it, which goes into an infinite loop The problem is that _read_from_database() finds out that you don't have access on the record, and stores a FailedValue in cache on all fields... except magic fields. Fix the problem by storing the FailedValue on all fields but 'id'. --- openerp/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/models.py b/openerp/models.py index 68a9ab64b95..0687e65a1ea 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -5657,7 +5657,7 @@ class RecordCache(MutableMapping): if args and isinstance(args[0], SpecialValue): values = dict.fromkeys(self._recs._ids, args[0]) for name, field in self._recs._fields.iteritems(): - if name not in MAGIC_COLUMNS: + if name != 'id': self._recs.env.cache[field].update(values) else: return super(RecordCache, self).update(*args, **kwargs) From 836245564ae7bb62449fb0b020cc991322066284 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 9 Jul 2014 15:34:51 +0200 Subject: [PATCH 2/2] [IMP] models: iterating over record._cache also returns log_access fields --- openerp/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index 0687e65a1ea..a9cac03dcb2 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -5675,8 +5675,7 @@ class RecordCache(MutableMapping): cache, id = self._recs.env.cache, self._recs.id dummy = SpecialValue(None) for name, field in self._recs._fields.iteritems(): - if name not in MAGIC_COLUMNS and \ - not isinstance(cache[field].get(id, dummy), SpecialValue): + if name != 'id' and not isinstance(cache[field].get(id, dummy), SpecialValue): yield name def __len__(self):