Do not set automatically as value the unique record found

As search is fuzzy (done with ilike) we need to ensure that the user validate
the value by selecting it.

Closes #11840
This commit is contained in:
Cédric Krier committed 2023-07-03 22:52:19 +02:00
1 parent 60e3544d81
commit b90baa9fac
3 files changed
+3 -18

No files matched your search

@@ -188,13 +188,7 @@ class Many2Many(Widget):
new=self.create_access,
title=self.attrs.get('string'))
win.screen.search_filter(quote(value))
if len(win.screen.group) == 1:
callback([
(r.id, r.value.get('rec_name', ''))
for r in win.screen.group])
win.destroy()
else:
win.show()
win.show()
def _sig_remove(self, *args):
self.screen.remove(remove=True)
@@ -137,13 +137,7 @@ class Many2One(Widget):
title=self.attrs.get('string'),
exclude_field=self.attrs.get('relation_field'))
win.screen.search_filter(quote(text))
if len(win.screen.group) == 1:
callback([
(r.id, r.value.get('rec_name', ''))
for r in win.screen.group])
win.destroy()
else:
win.show()
win.show()
return
self.focus_out = True
self.changed = True
@@ -829,10 +829,7 @@ class M2O(GenericText):
if model and common.get_toplevel_window().get_focus():
field = record[self.attrs['name']]
win = self.search_remote(record, field, text, callback=callback)
if len(win.screen.group) == 1:
win.response(None, Gtk.ResponseType.OK)
else:
win.show()
win.show()
def editing_started(self, cell, editable, path):
super(M2O, self).editing_started(cell, editable, path)