diff --git a/tryton/gui/window/dblogin.py b/tryton/gui/window/dblogin.py index 73024dc0af..cc89dde158 100644 --- a/tryton/gui/window/dblogin.py +++ b/tryton/gui/window/dblogin.py @@ -23,6 +23,7 @@ class DBListEditor(object): self.profiles = profiles self.current_database = None self.old_profile, self.current_profile = None, None + self.db_cache = None self.updating_db = False # GTK Stuffs @@ -290,6 +291,8 @@ class DBListEditor(object): port = self.port_entry.get_text() if not (host and port): return + if (host, port, self.current_profile['name']) == self.db_cache: + return if self.updating_db: return if dbname is None: @@ -307,6 +310,7 @@ class DBListEditor(object): def callback(dbs, createdb): self.updating_db = False + self.db_cache = (host, port, self.current_profile['name']) if dbs is None and createdb is None: pass @@ -343,6 +347,7 @@ class DBListEditor(object): port = int(self.port_entry.get_text()) dia = DBCreate(host, port) dbname = dia.run() + self.db_cache = None self.username_entry.set_text('admin') self.display_dbwidget(None, None, dbname) 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..b885336fe3 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() @@ -70,8 +71,9 @@ class Many2Many(WidgetInterface): frame.set_shadow_type(gtk.SHADOW_OUT) self.widget.pack_start(frame, expand=False, fill=True) - self.screen = Screen(attrs['relation'], mode=['tree'], - views_preload=attrs.get('views', {}), + self.screen = Screen(attrs['relation'], + view_ids=attrs.get('view_ids').split(','), + mode=['tree'], views_preload=attrs.get('views', {}), row_activate=self._on_activate) self.screen.signal_connect(self, 'record-message', self._sig_label) @@ -119,10 +121,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,20 +137,23 @@ 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() self.wid_text.set_text('') if len(ids) != 1 or not value: WinSearch(self.attrs['relation'], callback, sel_multi=True, - ids=ids, context=context, domain=domain, - views_preload=self.attrs.get('views', {})) + ids=ids, context=context, domain=domain, + views_ids=self.attrs.get('views_ids').split(','), + views_preload=self.attrs.get('views', {})) else: callback(ids) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py index 9f9b303939..700744cda8 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -160,6 +160,7 @@ class Many2One(WidgetInterface): WinSearch(model, callback, sel_multi=False, ids=ids, context=context, domain=domain, + view_ids=self.attrs.get('view_ids').split(','), views_preload=self.attrs.get('views', {})) return self.focus_out = True @@ -171,8 +172,8 @@ class Many2One(WidgetInterface): domain = self.field.domain_get(self.record) context = self.field.context_get(self.record) return Screen(self.get_model(), domain=domain, context=context, - mode=['form'], views_preload=self.attrs.get('views', {}), - readonly=self._readonly) + mode=['form'], view_ids=self.attrs.get('view_ids').split(','), + views_preload=self.attrs.get('views', {}), readonly=self._readonly) def sig_new(self, *args): self.focus_out = False @@ -249,6 +250,7 @@ class Many2One(WidgetInterface): self.changed = True WinSearch(model, callback, sel_multi=False, ids=ids, context=context, domain=domain, + view_ids=self.attrs.get('view_ids').split(','), views_preload=self.attrs.get('views', {})) return self.focus_out = True diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py index 992129698a..42ad8c7767 100644 --- a/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -158,6 +158,7 @@ class One2Many(WidgetInterface): self.screen = Screen(attrs['relation'], mode=attrs.get('mode', 'tree,form').split(','), + view_ids=attrs.get('view_ids', '').split(','), views_preload=attrs.get('views', {}), row_activate=self._on_activate, exclude_field=attrs.get('relation_field', None)) @@ -332,6 +333,7 @@ class One2Many(WidgetInterface): if len(ids) != 1: WinSearch(self.attrs['relation'], callback, sel_multi=True, ids=ids, context=context, domain=domain, + view_ids=self.attrs.get('view_ids', '').split(','), views_preload=self.attrs.get('views', {})) else: callback(ids) diff --git a/tryton/gui/window/win_form.py b/tryton/gui/window/win_form.py index 78f2b57fff..9212e1a939 100644 --- a/tryton/gui/window/win_form.py +++ b/tryton/gui/window/win_form.py @@ -281,7 +281,9 @@ class WinForm(NoModal): if len(ids) != 1: WinSearch(model_name, callback, sel_multi=True, - ids=ids, context=context, domain=domain) + ids=ids, context=context, domain=domain, + view_ids=self.attrs.get('view_ids').split(','), + views_preload=self.attrs.get('views', {})) else: callback(ids) diff --git a/tryton/gui/window/win_search.py b/tryton/gui/window/win_search.py index 87ef2c4ddf..1ee69d4830 100644 --- a/tryton/gui/window/win_search.py +++ b/tryton/gui/window/win_search.py @@ -14,7 +14,7 @@ _ = gettext.gettext class WinSearch(NoModal): def __init__(self, model, callback, sel_multi=True, ids=None, context=None, - domain=None, views_preload=None): + domain=None, view_ids=None, views_preload=None): NoModal.__init__(self) if views_preload is None: views_preload = {} @@ -50,7 +50,7 @@ class WinSearch(NoModal): self.win.vbox.pack_start(scrollwindow, expand=True, fill=True) self.screen = Screen(model, domain=domain, mode=['tree'], - context=context, views_preload=views_preload, + context=context, view_ids=view_ids, views_preload=views_preload, row_activate=self.sig_activate) self.view = self.screen.current_view self.view.unset_editable()