From 040842977ec7235d413e421df02f37bd076a1c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 22 Oct 2024 01:39:29 +0200 Subject: [PATCH] Support widget with search_remote when pasting rows Since 4db597e5b08c the widget value is not set automatically if there is only one result. Closes #13612 (grafted from cade754efb2b09b282576dbdae9d6770c12b1777) --HG-- branch : 7.0 --- tryton/tryton/gui/window/view_form/view/list.py | 13 ++++++++++++- 1 file changed, 12 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 a832ec35ad..29cdf2b420 100644 --- a/tryton/tryton/gui/window/view_form/view/list.py +++ b/tryton/tryton/gui/window/view_form/view/list.py @@ -785,7 +785,18 @@ class ViewTree(View): for col, value in zip(columns, line): widget = self.get_column_widget(col) if widget.get_textual_value(record) != value: - widget.value_from_text(record, value) + if hasattr(widget, 'search_remote'): + field = record.group.fields[widget.attrs['name']] + win = widget.search_remote(record, field, value) + if len(win.screen.group) == 1: + target, = win.screen.group + field.set_client( + record, (target.id, target.rec_name())) + else: + field.set_client(record, (None, '')) + win.response(win, Gtk.ResponseType.CANCEL) + else: + widget.value_from_text(record, value) if value and not widget.get_textual_value(record): # Stop setting value if a value is correctly set idx = len(group)