From fdd00582b698ac47cd4ef2108d2c214c07c8a34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 26 Mar 2025 20:07:54 +0100 Subject: [PATCH] Change current record for the first selected only if there is no current record #4028 added the behavior to apply the selected record also on form view the first time. But when switching to a calendar view from a form view, the tree states is stored with the current record. If the calendar view is cleared (always with sao via the search_filter), then the tree_states_done is cleared and on the second switch to the form view the current record is override by record stored in the tree states (from the first form switch). Closes #13939 (grafted from 5719977cd18ed02fc485a0bc8be4abc6b4aec6b3) --HG-- branch : 7.0 --- sao/src/screen.js | 3 ++- tryton/tryton/gui/window/view_form/screen/screen.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sao/src/screen.js b/sao/src/screen.js index 06e40cc5b4..641b1e17bc 100644 --- a/sao/src/screen.js +++ b/sao/src/screen.js @@ -2275,7 +2275,8 @@ return view.display(selected_nodes); } else { var record; - if (!jQuery.isEmptyObject(selected_nodes)) { + if (!jQuery.isEmptyObject(selected_nodes) && + !this.current_record) { for (const id of selected_nodes[0]) { const new_record = this.group.get(id); if (!new_record) { diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index 136349fa85..0f499ecbe0 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -879,7 +879,7 @@ class Screen: view.expand_nodes(expanded_nodes) view.select_nodes(selected_nodes) else: - if selected_nodes: + if selected_nodes and not self.current_record: record = None for node in selected_nodes[0]: new_record = self.group.get(node)