Fix readonly tests when user has only create access

The screen should not be read-only if the user is allowed to create record even
if he is not allowed to modify it. And it is the same for the save button.

issue5479
review20151002
This commit is contained in:
Cédric Krier committed 2016-04-21 17:15:08 +02:00
1 parent 6eb88eb563
commit 52fcbba9df
3 files changed
+9 -5

No files matched your search

+5 -3
View File
@@ -332,8 +332,9 @@ class Form(SignalEvent, TabContent):
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]
self.buttons['new'].props.sensitive = access['create']
self.buttons['save'].props.sensitive = (
access['create'] or access['write'])
else:
for button in ['new', 'save']:
self.buttons[button].props.sensitive = False
@@ -384,7 +385,8 @@ class Form(SignalEvent, TabContent):
if widget:
# Called from button so we must save the tree state
self.screen.save_tree_state()
if not common.MODELACCESS[self.model]['write']:
if not (common.MODELACCESS[self.model]['write']
or common.MODELACCESS[self.model]['create']):
return
if self.screen.save_current():
self.message_info(_('Record saved.'), gtk.MESSAGE_INFO)
+2 -1
View File
@@ -44,7 +44,8 @@ class Group(SignalEvent, list):
def readonly(self):
# Must skip res.user for Preference windows
if (self._context.get('_datetime')
or (not MODELACCESS[self.model_name]['write']
or (not (MODELACCESS[self.model_name]['write']
or MODELACCESS[self.model_name]['create'])
and not self.skip_model_access)):
return True
return self.__readonly
+2 -1
View File
@@ -59,7 +59,8 @@ class Screen(SignalEvent):
super(Screen, self).__init__()
self.readonly = readonly
if not MODELACCESS[model_name]['write']:
if not (MODELACCESS[model_name]['write']
or MODELACCESS[model_name]['create']):
self.readonly = True
self.search_count = 0
if not row_activate: