From 6bae798031ffa42add9cb1f2385e5ac71e092956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 1 Mar 2024 18:06:33 +0100 Subject: [PATCH] Remove unnecessary preference keys from RPC context The locale key is only used by the client to properly format in the locale. And the '.rec_name' keys are used by preferences dialog. Closes #13068 --- sao/src/session.js | 2 ++ tryton/tryton/common/common.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sao/src/session.js b/sao/src/session.js index ab2d667e4f..4f61ddee58 100644 --- a/sao/src/session.js +++ b/sao/src/session.js @@ -112,6 +112,8 @@ this.reset_context(); var prm = Sao.rpc(args, this); return prm.then(context => { + context = Object.fromEntries(Object.entries(context).filter( + ([k, v]) => (k != 'locale') && !k.endsWith('.rec_name'))); jQuery.extend(this.context, context); this.store_context(); }); diff --git a/tryton/tryton/common/common.py b/tryton/tryton/common/common.py index 481df9602f..a5ca775f07 100644 --- a/tryton/tryton/common/common.py +++ b/tryton/tryton/common/common.py @@ -1293,10 +1293,15 @@ def RPCExecute(*args, **kwargs): def RPCContextReload(callback=None): + def clean(context): + return { + k: v for k, v in context.items() + if k != 'locale' and not k.endswith('.rec_name')} + def update(context): rpc.context_reset() try: - rpc.CONTEXT.update(context()) + rpc.CONTEXT.update(clean(context())) except RPCException: pass if callback: @@ -1306,7 +1311,7 @@ def RPCContextReload(callback=None): callback=update if callback else None) if not callback: rpc.context_reset() - rpc.CONTEXT.update(context) + rpc.CONTEXT.update(clean(context)) class Tooltips(object):