Please review this at http://codereview.tryton.org/233004/
Affected files:
M tryton/gui/window/view_form/view/form_gtk/many2many.py
Index: tryton/gui/window/view_form/view/form_gtk/many2many.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/many2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py
@@ -37,6 +37,7 @@
self.wid_text.set_property('width_chars', 13)
self.wid_text.connect('activate', self._sig_activate)
self.wid_text.connect('focus-out-event', self._focus_out)
+ self.focus_out = True
hbox.pack_start(self.wid_text, expand=True, fill=True)
self.but_add = gtk.Button()
@@ -119,10 +120,13 @@
self._sig_add()
def _sig_add(self, *args):
+ if not self.focus_out:
+ return
domain = self.field.domain_get(self.record)
context = self.field.context_get(self.record)
value = self.wid_text.get_text()
+ self.focus_out = False
try:
if value:
dom = [('rec_name', 'ilike', '%' + value + '%'), domain]
@@ -132,12 +136,14 @@
dom, 0, CONFIG['client.limit'], None, context)
except TrytonServerError, exception:
common.process_exception(exception)
+ self.focus_out = True
return False
def callback(ids):
res_id = None
if ids:
res_id = ids[0]
+ self.focus_out = True
self.screen.load(ids, modified=True)
self.screen.display(res_id=res_id)
self.screen.set_cursor()