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
This commit is contained in:
Cédric Krier
2024-10-22 01:39:29 +02:00
parent 6d88e103f7
commit 040842977e
@@ -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)