From 28bee40debbae2fee02f89d783a9ad222a0ba59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 23 Jan 2022 13:27:52 +0100 Subject: [PATCH] Limit board action domain to active id and ids And use a dedicated _actions dictionary to store the active ids per action ids. issue11106 review389591002 --- CHANGELOG | 1 + tryton/gui/window/view_board/action.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 887b3188b6..821f74ec9b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Limit board action domain to active id and ids * Add support for Python 3.10 * Remove support for Python 3.6 * Manage creatable attribute of view diff --git a/tryton/gui/window/view_board/action.py b/tryton/gui/window/view_board/action.py index 256c87f22b..04174a1861 100644 --- a/tryton/gui/window/view_board/action.py +++ b/tryton/gui/window/view_board/action.py @@ -5,7 +5,6 @@ import gettext from gi.repository import GLib, Gtk -import tryton.common as common import tryton.rpc as rpc from tryton.action import Action as GenericAction from tryton.common import RPCException, RPCExecute @@ -50,7 +49,6 @@ class Action: ctx['context'] = ctx decoder = PYSONDecoder(ctx) - self.domain = decoder.decode(self.action['pyson_domain']) order = decoder.decode(self.action['pyson_order']) search_value = decoder.decode( self.action['pyson_search_value'] or '[]') @@ -136,17 +134,23 @@ class Action: def _get_active(self): if self.screen and self.screen.current_record: - return common.EvalEnvironment(self.screen.current_record) + return { + 'active_id': self.screen.current_record.id, + 'active_ids': [r.id for r in self.screen.selected_records] + } + else: + return { + 'active_id': None, + 'active_ids': [], + } active = property(_get_active) def update_domain(self, actions): domain_ctx = self.context.copy() - domain_ctx['context'] = domain_ctx - domain_ctx['_user'] = rpc._USER + domain_ctx['_actions'] = {} for action in actions: - if action.active: - domain_ctx[action.name] = action.active + domain_ctx['_actions'][action.name] = action.active new_domain = PYSONDecoder(domain_ctx).decode( self.action['pyson_domain']) if self.domain == new_domain: