[FIX] api: share protected among environments

If a field is protected against recomputation, it must be protected in
*all* environments.
This commit is contained in:
Raphael Collet
2019-08-23 10:00:12 +00:00
parent ec3c76dc77
commit e388efd059
2 changed files with 2 additions and 4 deletions
+2 -1
View File
@@ -452,7 +452,7 @@ class Environment(Mapping):
self.cr, self.uid, self.context, self.su = self.args = args
self.registry = Registry(cr.dbname)
self.cache = envs.cache
self._protected = StackMap() # {field: ids, ...}
self._protected = envs.protected # proxy to shared data structure
self.all = envs
envs.add(self)
return self
@@ -668,6 +668,7 @@ class Environments(object):
def __init__(self):
self.envs = WeakSet() # weak set of environments
self.cache = Cache() # cache for all records
self.protected = StackMap() # fields to protect {field: ids, ...}
self.tocompute = defaultdict(set) # recomputations {field: ids}
# updates {model: {id: {field: value}}}
self.towrite = defaultdict(lambda: defaultdict(dict))
-3
View File
@@ -2569,9 +2569,6 @@ class _RelationalMulti(_Relational):
cache.set(record, self, val)
else:
result = False
# DEEP FUCKING HACK TO FIX SOMEDAY: recs.env is different from
# records.env; we must trigger modifications in the original env
recs.env._protected = records.env._protected
recs.modified([self.name])
return result