From 5f660cdb283d6227cf38a5192967bb7edd600622 Mon Sep 17 00:00:00 2001 From: rco-odoo Date: Wed, 6 Dec 2017 15:05:15 +0100 Subject: [PATCH] [FIX] models: avoid wild prefetching when serializing onchange results We fell on a strange situation in method `onchange`, where some data was missing from cache when serializing the result. In that case, the prefetching overwrites so many stuff in cache that the results of the onchanges are lost. Don't let that happen. --- odoo/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/odoo/models.py b/odoo/models.py index 9a5fb28218e..2086c137a61 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -5031,10 +5031,11 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): subtree = subtree[name] # collect values from dirty fields - result['value'] = { - name: self._fields[name].convert_to_onchange(record[name], record, subnames[name]) - for name in dirty - } + with env.do_in_onchange(): + result['value'] = { + name: self._fields[name].convert_to_onchange(record[name], record, subnames[name]) + for name in dirty + } return result