Call directly the callback when search has a unique result

We can not rely on the response because it is using the selection which may not
be filled.

issue11632
review411541003
(grafted from 3213c545da10db54ded880a5dd98f6d90bbf5822)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2022-08-08 22:21:49 +02:00
1 parent 86bbfb2af6
commit 9f76b6875e
2 files changed
+8 -2

No files matched your search

@@ -164,7 +164,10 @@ class Many2Many(Widget):
title=self.attrs.get('string'))
win.screen.search_filter(quote(value))
if len(win.screen.group) == 1:
win.response(None, Gtk.ResponseType.OK)
callback([
(r.id, r.value.get('rec_name', ''))
for r in win.screen.group])
win.destroy()
else:
win.show()
@@ -136,7 +136,10 @@ class Many2One(Widget):
exclude_field=self.attrs.get('relation_field'))
win.screen.search_filter(quote(text))
if len(win.screen.group) == 1:
win.response(None, Gtk.ResponseType.OK)
callback([
(r.id, r.value.get('rec_name', ''))
for r in win.screen.group])
win.destroy()
else:
win.show()
return