From 59eec8711c95edf8aa4c040532486a3677441644 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 11 Jan 2024 11:25:40 +0100 Subject: [PATCH] [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 --- odoo/tests/form.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/odoo/tests/form.py b/odoo/tests/form.py index ce2ed75b84e..abf641a86a7 100644 --- a/odoo/tests/form.py +++ b/odoo/tests/form.py @@ -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)