From 71613d9eab1e0823b8059989afbf8fa05eb80116 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 18 Sep 2018 14:06:27 +0200 Subject: [PATCH] [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. --- odoo/fields.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/odoo/fields.py b/odoo/fields.py index 19fed759435..ea232738109 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -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))