From 91d291cbf4c23d2f736e69557a248de140832147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 24 Sep 2020 23:00:52 +0200 Subject: [PATCH] Allow sharing view searches We add a rule to give read access to all view searches without a user. We manage the delete access on client side thanks to the _delete attribute. If the user does not have the delete right, the bookmark star is disabled. issue9515 review323751002 --- tryton/common/common.py | 2 +- .../window/view_form/view/screen_container.py | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tryton/common/common.py b/tryton/common/common.py index cde7a246b2..2fbe69d2da 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -259,7 +259,7 @@ class ViewSearch(object): }]) except RPCException: return - self.searches.setdefault(model, []).append((id_, name, domain)) + self.searches.setdefault(model, []).append((id_, name, domain, True)) def remove(self, model, id_): try: diff --git a/tryton/gui/window/view_form/view/screen_container.py b/tryton/gui/window/view_form/view/screen_container.py index 7769413eb4..2ba59f85b2 100644 --- a/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/gui/window/view_form/view/screen_container.py @@ -242,7 +242,7 @@ class ScreenContainer(object): widget_allocation.x, widget_allocation.y) return (x, y + widget_allocation.height, False) - for id_, name, domain in self.bookmarks(): + for id_, name, domain, access in self.bookmarks(): menuitem = Gtk.MenuItem(label=name) menuitem.connect('activate', self.bookmark_activate, domain) menu.add(menuitem) @@ -407,9 +407,10 @@ class ScreenContainer(object): self.bookmark_match() def bookmarks(self): - for id_, name, domain in common.VIEW_SEARCH[self.screen.model_name]: + for id_, name, domain, access in common.VIEW_SEARCH[ + self.screen.model_name]: if self.screen.domain_parser.stringable(domain): - yield id_, name, domain + yield id_, name, domain, access def bookmark_activate(self, menuitem, domain): self.set_text(self.screen.domain_parser.string(domain)) @@ -419,11 +420,7 @@ class ScreenContainer(object): current_text = self.get_text() if current_text: current_domain = self.screen.domain_parser.parse(current_text) - self.search_entry.set_icon_activatable( - Gtk.EntryIconPosition.SECONDARY, bool(current_text)) - self.search_entry.set_icon_sensitive( - Gtk.EntryIconPosition.SECONDARY, bool(current_text)) - for id_, name, domain in self.bookmarks(): + for id_, name, domain, access in self.bookmarks(): text = self.screen.domain_parser.string(domain) domain = self.screen.domain_parser.parse(text) if (text == current_text @@ -435,7 +432,15 @@ class ScreenContainer(object): self.search_entry.set_icon_tooltip_text( Gtk.EntryIconPosition.SECONDARY, _('Remove this bookmark')) + self.search_entry.set_icon_activatable( + Gtk.EntryIconPosition.SECONDARY, access) + self.search_entry.set_icon_sensitive( + Gtk.EntryIconPosition.SECONDARY, access) return id_ + self.search_entry.set_icon_activatable( + Gtk.EntryIconPosition.SECONDARY, bool(current_text)) + self.search_entry.set_icon_sensitive( + Gtk.EntryIconPosition.SECONDARY, bool(current_text)) self.search_entry.set_icon_from_pixbuf( Gtk.EntryIconPosition.SECONDARY, common.IconFactory.get_pixbuf(