From 34d34b682cd42de7b48f21d587bc2a7dce0b882b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 24 Sep 2024 14:46:39 +0200 Subject: [PATCH] Ensure current record is in the tree view selection --- tryton/tryton/gui/window/view_form/view/list.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tryton/tryton/gui/window/view_form/view/list.py b/tryton/tryton/gui/window/view_form/view/list.py index 24d3b5400b..17f72263a7 100644 --- a/tryton/tryton/gui/window/view_form/view/list.py +++ b/tryton/tryton/gui/window/view_form/view/list.py @@ -1125,9 +1125,14 @@ class ViewTree(View): selection.select_path(path) # The search column must be set each time the model is changed self.treeview.set_search_column(0) + selection = self.treeview.get_selection() if not current_record: - selection = self.treeview.get_selection() selection.unselect_all() + else: + model = self.treeview.get_model() + path = Gtk.TreePath(current_record.get_index_path(model.group)) + if not selection.path_is_selected(path): + selection.select_path(path) self.treeview.queue_draw() if self.editable: self.set_state() @@ -1263,6 +1268,8 @@ class ViewTree(View): records = [] sel = self.treeview.get_selection() sel.selected_foreach(_func_sel_get, records) + if not records and self.record: + records.append(self.record) return records def get_selected_paths(self):