[FIX] fields: avoid _update to raise AccessError

During an onchange, setting a many2one field automatically updates its inverse
one2many field.  If the update raises an exception, catch it and put it in
cache, so that it is re-raised when the value is read from the cache.
This commit is contained in:
Raphael Collet
2018-09-18 16:00:32 +02:00
parent fe9612c6bc
commit 71613d9eab
+6 -2
View File
@@ -2155,8 +2155,12 @@ class _RelationalMulti(_Relational):
cache = records.env.cache
for record in records:
if cache.contains(record, self):
val = self.convert_to_cache(record[self.name] | value, record, validate=False)
cache.set(record, self, val)
try:
val = self.convert_to_cache(record[self.name] | value, record, validate=False)
cache.set(record, self, val)
except Exception as exc:
# delay the failure until the field is necessary
cache.set_failed(record, [self], exc)
else:
cache.set_special(record, self, self._update_getter(record, value))