summaryrefslogtreecommitdiff
path: root/odoo/api.py
diff options
context:
space:
mode:
authorRémy Voet (ryv) <ryv@odoo.com>2024-04-08 09:02:26 +0200
committerRémy Voet (ryv) <ryv@odoo.com>2024-05-08 07:46:35 +0000
commit6a8f2cd3d2676d1c7e38aa4c1862a66cd00a2392 (patch)
tree07835289668541e39becd1ca64da6a269c6cd391 /odoo/api.py
parent5f0c6e436ce1065e5c1c8067fbf361539f6e1917 (diff)
[FIX] core: fix create/write on binary fields
When invoking create() or write() with a binary field, the cache of the field was incorrect if bin_size=True was in context. Force context with bin_size=False when putting a binary value in cache. It is particularly important to have coherent values in the cache for `web_save`. Also, because an environment with bin_size=False won't return the same context cache key as one with bin_size=None, it leads to have a cache inconstistency when we write with bin_size=False. Change Environment method cache_key() to return the same cache key when bin_size is absent, bin_size=None or bin_size=False. Tests on binary fields have been updated to not rely on flush and invalidate. We also created specific tests for write() on binary fields. X-original-commit: 1885531115106f7d7178227ab41f5729b56d42f7 Part-of: odoo/odoo#164061
Diffstat (limited to 'odoo/api.py')
-rw-r--r--odoo/api.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/odoo/api.py b/odoo/api.py
index 19210a0d303..af55a361315 100644
--- a/odoo/api.py
+++ b/odoo/api.py
@@ -825,6 +825,8 @@ class Environment(Mapping):
return get_context('lang') or None
elif key == 'active_test':
return get_context('active_test', field.context.get('active_test', True))
+ elif key.startswith('bin_size'):
+ return bool(get_context(key))
else:
val = get_context(key)
if type(val) is list: