From fc15fedb07772cc262279afb16f2f8d8d201abf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 31 Jan 2012 13:07:35 +0100 Subject: [PATCH] Better management of focus out in Many2Many review233004 --- tryton/gui/window/view_form/view/form_gtk/many2many.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/gui/window/view_form/view/form_gtk/many2many.py index 878c684db0..9b7eef1199 100644 --- 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 @@ class Many2Many(WidgetInterface): 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 @@ class Many2Many(WidgetInterface): 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 @@ class Many2Many(WidgetInterface): 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()