mirror of
https://github.com/NaN-tic/sao-base.git
synced 2023-12-14 03:13:01 +01:00
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:
parent
8af79f3fc6
commit
a91bddae79
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
11
src/tab.js
11
src/tab.js
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue