changeset 3213c545da10 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset&node=3213c545da10
description:
        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
diffstat:

 tryton/gui/window/view_form/view/form_gtk/many2many.py |  5 ++++-
 tryton/gui/window/view_form/view/form_gtk/many2one.py  |  5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diffs (30 lines):

diff -r ffe15dec2528 -r 3213c545da10 
tryton/gui/window/view_form/view/form_gtk/many2many.py
--- a/tryton/gui/window/view_form/view/form_gtk/many2many.py    Sat Aug 06 
22:57:57 2022 +0200
+++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py    Mon Aug 08 
22:21:49 2022 +0200
@@ -180,7 +180,10 @@
             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()
 
diff -r ffe15dec2528 -r 3213c545da10 
tryton/gui/window/view_form/view/form_gtk/many2one.py
--- a/tryton/gui/window/view_form/view/form_gtk/many2one.py     Sat Aug 06 
22:57:57 2022 +0200
+++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py     Mon Aug 08 
22:21:49 2022 +0200
@@ -137,7 +137,10 @@
                     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

Reply via email to