[FIX] core: avoid hiding access error in onchange() with Form

When the server-side form view reads its record, the call to web_read()
leaves data in cache, which may prevent some access error to be
triggered in the first call to onchange().  In order to avoid that,
simply clean up the environment like after the other method calls.

Part-of: odoo/odoo#148997
This commit is contained in:
Raphael Collet
2024-01-11 17:00:50 +00:00
parent 13649e6b46
commit 59eec8711c
+4
View File
@@ -283,7 +283,11 @@ class Form:
""" Initialize the form for an existing record. """
assert self._record.id, "editing unstored records is not supported"
self._values.clear()
[record_values] = self._record.web_read(self._view['fields_spec'])
self._env.flush_all()
self._env.clear() # discard cache and pending recomputations
values = convert_read_to_form(record_values, self._view['fields'])
self._values.update(values)