From 266eb42fcc7b788f47a39e58583f0ea7c2bdd8a2 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 26 Mar 2018 14:26:33 +0200 Subject: [PATCH] Manage active field on search widget issue4341 review40411002 --- CHANGELOG | 1 + tryton/data/pixmaps/tryton/tryton-archive.svg | 317 ++++++++++++++++++ tryton/gui/window/view_form/screen/screen.py | 17 +- .../window/view_form/view/screen_container.py | 24 ++ 4 files changed, 357 insertions(+), 2 deletions(-) create mode 100644 tryton/data/pixmaps/tryton/tryton-archive.svg diff --git a/CHANGELOG b/CHANGELOG index fd7463e690..82eff21ddc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Manage active field on search widget * Reset record to its original state when discarding the popup window * Add support of expand attribute on group tag * Add the context model name in the screen context diff --git a/tryton/data/pixmaps/tryton/tryton-archive.svg b/tryton/data/pixmaps/tryton/tryton-archive.svg new file mode 100644 index 0000000000..99ad454a49 --- /dev/null +++ b/tryton/data/pixmaps/tryton/tryton-archive.svg @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + File Manager + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + file + manager + copy + move + filesystem + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index 64a0be969f..8721b0ce9f 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -187,6 +187,11 @@ class Screen(SignalEvent): fields = collections.OrderedDict( (name, fields[name]) for name in xml_fields) + if 'active' in view_tree['fields']: + self.screen_container.but_active.show() + else: + self.screen_container.but_active.hide() + # Add common fields for name, string, type_ in ( ('id', _('ID'), 'integer'), @@ -254,16 +259,19 @@ class Screen(SignalEvent): if tab_domain: domain = ['AND', domain, tab_domain] + context = self.context + if self.screen_container.but_active.get_active(): + context['active_test'] = False try: ids = RPCExecute('model', self.model_name, 'search', domain, - self.offset, self.limit, self.order, context=self.context) + self.offset, self.limit, self.order, context=context) except RPCException: ids = [] if not only_ids: if self.limit is not None and len(ids) == self.limit: try: self.search_count = RPCExecute('model', self.model_name, - 'search_count', domain, context=self.context) + 'search_count', domain, context=context) except RPCException: self.search_count = 0 else: @@ -302,6 +310,11 @@ class Screen(SignalEvent): else: domain = self.domain + if self.screen_container.but_active.get_active(): + if domain: + domain = [domain, ('active', '=', False)] + else: + domain = [('active', '=', False)] if self.current_view and self.current_view.view_type == 'calendar': if domain: domain = ['AND', domain, self.current_view.current_domain()] diff --git a/tryton/gui/window/view_form/view/screen_container.py b/tryton/gui/window/view_form/view/screen_container.py index 0cb78c3e31..9e62994428 100644 --- a/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/gui/window/view_form/view/screen_container.py @@ -192,6 +192,18 @@ class ScreenContainer(object): def deactivate(menuitem, togglebutton): togglebutton.props.active = False + but_active = gtk.ToggleButton() + self.but_active = but_active + self._set_active_tooltip() + img_active = gtk.Image() + img_active.set_from_stock( + 'tryton-archive', gtk.ICON_SIZE_SMALL_TOOLBAR) + img_active.set_alignment(0.5, 0.5) + but_active.add(img_active) + but_active.set_relief(gtk.RELIEF_NONE) + but_active.connect('toggled', self.search_active) + hbox.pack_start(but_active, expand=False, fill=False) + but_bookmark = gtk.ToggleButton() self.but_bookmark = but_bookmark tooltips.set_tip(but_bookmark, _('Show bookmarks of filters')) @@ -383,6 +395,18 @@ class ScreenContainer(object): def search_prev(self, widget=None): self.screen.search_prev(self.get_text()) + def search_active(self, widget=None): + self._set_active_tooltip() + self.screen.search_filter(self.get_text()) + + def _set_active_tooltip(self): + if self.but_active.get_active(): + tooltip = _('Show active records') + else: + tooltip = _('Show inactive records') + tooltips = common.Tooltips() + tooltips.set_tip(self.but_active, tooltip) + def switch_page(self, notebook, page, page_num): current_page = notebook.get_nth_page(notebook.get_current_page()) current_page.remove(self.viewport)