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
review19201002
This commit is contained in:
C?dric Krier 2016-04-21 17:15:52 +02:00
parent 8af79f3fc6
commit a91bddae79
3 changed files with 11 additions and 6 deletions

View file

@ -106,8 +106,9 @@
});
array.get_readonly = function() {
// Must skip res.user for Preference windows
var access = Sao.common.MODELACCESS.get(this.model.name);
if (this.context._datetime ||
(!Sao.common.MODELACCESS.get(this.model.name).write &&
(!(access.write || access.create) &&
!this.skip_model_access)) {
return true;
}

View file

@ -600,7 +600,8 @@
this.size_limit = null;
this.limit = attributes.limit || Sao.config.limit;
this.offset = 0;
if (!Sao.common.MODELACCESS.get(model_name).write) {
var access = Sao.common.MODELACCESS.get(model_name);
if (!(access.write || access.create)) {
this.attributes.readonly = true;
}
this.search_count = 0;

View file

@ -505,7 +505,8 @@
}.bind(this));
},
save: function() {
if (!Sao.common.MODELACCESS.get(this.screen.model_name).write) {
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
if (!(access.write || access.create)) {
return jQuery.when();
}
return this.screen.save_current().then(
@ -709,10 +710,12 @@
set_buttons_sensitive: function(revision) {
if (!revision) {
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
[['new', 'create'], ['save', 'write']].forEach(function(e) {
[['new', access.create],
['save', access.create || access.write]
].forEach(function(e) {
var button = e[0];
var access_type = e[1];
if (access[access_type]) {
var access = e[1];
if (access) {
this.buttons[button].parent().removeClass('disabled');
} else {
this.buttons[button].parent().addClass('disabled');