From c3ee8e2dea5f13a112cbce4a911c37998ec61e37 Mon Sep 17 00:00:00 2001 From: Pablo Padulles Date: Thu, 21 Jan 2016 10:23:12 +0100 Subject: [PATCH] Disable new and save buttons when the user is not allowed to create new records The revision update should not overrule the model access. issue4902 review24611002 --- tryton/gui/window/form.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tryton/gui/window/form.py b/tryton/gui/window/form.py index 6f6fa0cbae..61b1863f9a 100644 --- a/tryton/gui/window/form.py +++ b/tryton/gui/window/form.py @@ -133,12 +133,7 @@ class Form(SignalEvent, TabContent): style.bg[gtk.STATE_INSENSITIVE]) self.widget.pack_start(url_entry, False, False) - access = common.MODELACCESS[self.model] - for button, access_type in ( - ('new', 'create'), - ('save', 'write'), - ): - self.buttons[button].props.sensitive = access[access_type] + self.set_buttons_sensitive() self.screen.signal_connect(self, 'record-message', self._record_message) @@ -297,8 +292,16 @@ class Form(SignalEvent, TabContent): self.title.set_label('%s @ %s' % (self.name, revision)) else: self.title.set_label(self.name) - for button in ('new', 'save'): - self.buttons[button].props.sensitive = not revision + self.set_buttons_sensitive(revision) + + def set_buttons_sensitive(self, revision=None): + if not revision: + access = common.MODELACCESS[self.model] + for button, access_type in [('new', 'create'), ('save', 'write')]: + self.buttons[button].props.sensitive = access[access_type] + else: + for button in ['new', 'save']: + self.buttons[button].props.sensitive = False def sig_remove(self, widget=None): if not common.MODELACCESS[self.model]['delete']: