From f6e2367dc3bf26aaa22494e730dba6009d3f3d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 Jan 2025 16:10:10 +0100 Subject: [PATCH] Use saved tree state to restore selected record on form view Closes #13822 (grafted from f8ca5d7c17c68f332f11bfafeee8d9222257a861) --HG-- branch : 7.0 --- tryton/tryton/gui/window/view_form/screen/screen.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index 25805b1b17..c7ca034778 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -852,11 +852,12 @@ class Screen: parent = self.parent.id if self.parent else None if parent is not None and parent < 0: return - expanded_nodes, selected_nodes = [], [] + state = self.tree_states[parent][view.children_field] + if state: + expanded_nodes, selected_nodes = state + else: + expanded_nodes, selected_nodes = [], [] if view.view_type in {'tree', 'list-form'}: - state = self.tree_states[parent][view.children_field] - if state: - expanded_nodes, selected_nodes = state if (state is None and CONFIG['client.save_tree_state'] and int(view.attributes.get('tree_state', False))):