Manage deletable and writable state from ir.rule
issue9357 review290101002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Manage deletable and writable state
|
||||
* Support e-mail template
|
||||
* Always encode CSV export in UTF-8
|
||||
* Use tempusdominus and Popper for date time picker
|
||||
|
||||
+15
-1
@@ -551,6 +551,8 @@
|
||||
this._loaded = {};
|
||||
this.fields = {};
|
||||
this._timestamp = null;
|
||||
this._write = true;
|
||||
this._delete = true;
|
||||
this.resources = null;
|
||||
this.button_clicks = {};
|
||||
this.links_counts = {};
|
||||
@@ -685,6 +687,8 @@
|
||||
fnames_to_fetch.push('rec_name');
|
||||
}
|
||||
fnames_to_fetch.push('_timestamp');
|
||||
fnames_to_fetch.push('_write');
|
||||
fnames_to_fetch.push('_delete');
|
||||
|
||||
var context = jQuery.extend({}, this.get_context());
|
||||
if (loading == 'eager') {
|
||||
@@ -813,6 +817,10 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (name == '_write' || name == '_delete') {
|
||||
this[name] = value;
|
||||
continue;
|
||||
}
|
||||
if (!(name in this.model.fields)) {
|
||||
if (name == 'rec_name') {
|
||||
this._values[name] = value;
|
||||
@@ -1342,7 +1350,13 @@
|
||||
return Boolean(~this.group.record_removed.indexOf(this));
|
||||
},
|
||||
get readonly() {
|
||||
return this.deleted || this.removed || this.exception;
|
||||
return (this.deleted ||
|
||||
this.removed ||
|
||||
this.exception ||
|
||||
!this._write);
|
||||
},
|
||||
get deletable() {
|
||||
return this._delete;
|
||||
},
|
||||
get identity() {
|
||||
return JSON.stringify(
|
||||
|
||||
+21
-2
@@ -813,6 +813,17 @@
|
||||
// switch_view to avoid unnecessary call to fields_view_get by
|
||||
// domain_parser.
|
||||
},
|
||||
get readonly() {
|
||||
var readonly_records = this.selected_records.some(function(r) {
|
||||
return r.readonly;
|
||||
});
|
||||
return this.attributes.readonly || readonly_records;
|
||||
},
|
||||
get deletable() {
|
||||
return this.selected_records.every(function(r) {
|
||||
return r.deletable;
|
||||
});
|
||||
},
|
||||
load_next_view: function() {
|
||||
if (!jQuery.isEmptyObject(this.view_to_load)) {
|
||||
var view_id;
|
||||
@@ -1181,7 +1192,7 @@
|
||||
context = this.context;
|
||||
}
|
||||
var group = new Sao.Group(this.model, context, []);
|
||||
group.readonly = this.attributes.readonly || false;
|
||||
group.readonly = this.attributes.readonly;
|
||||
this.set_group(group);
|
||||
},
|
||||
get current_record() {
|
||||
@@ -1328,6 +1339,12 @@
|
||||
this.set_cursor(false, false);
|
||||
return view.display();
|
||||
},
|
||||
get selected_records() {
|
||||
if (this.current_view) {
|
||||
return this.current_view.selected_records;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
clear: function() {
|
||||
this.current_record = null;
|
||||
this.group.clear();
|
||||
@@ -1902,7 +1919,9 @@
|
||||
this.new_();
|
||||
}
|
||||
} else if (action == 'delete') {
|
||||
if (access['delete']) {
|
||||
if (access['delete'] && (
|
||||
this.current_record ? this.current_record.deletable :
|
||||
true)) {
|
||||
this.remove(!this.group.parent, false, !this.group.parent);
|
||||
}
|
||||
} else if (action == 'remove') {
|
||||
|
||||
@@ -1288,6 +1288,12 @@
|
||||
}.bind(this));
|
||||
this.buttons.switch_.prop('disabled',
|
||||
this.attributes.view_ids > 1);
|
||||
|
||||
this.menu_buttons.delete_.toggleClass(
|
||||
'disabled', !this.screen.deletable);
|
||||
this.menu_buttons.save.toggleClass(
|
||||
'disabled', this.screen.readonly);
|
||||
|
||||
var msg = name + ' / ' + data[1];
|
||||
if (data[1] < data[2]) {
|
||||
msg += Sao.i18n.gettext(' of ') + data[2];
|
||||
|
||||
+6
-3
@@ -3034,6 +3034,7 @@ function eval_pyson(value){
|
||||
o2m_size = null;
|
||||
size_limit = false;
|
||||
}
|
||||
var deletable = this.screen.deletable;
|
||||
var create = this.attributes.create;
|
||||
if (create === undefined) {
|
||||
create = true;
|
||||
@@ -3046,7 +3047,7 @@ function eval_pyson(value){
|
||||
delete_ = true;
|
||||
}
|
||||
this.but_del.prop('disabled', this._readonly || !delete_ ||
|
||||
!access['delete'] || !this._position);
|
||||
!access['delete'] || !this._position || !deletable);
|
||||
this.but_undel.prop('disabled', this._readonly || size_limit ||
|
||||
!this._position);
|
||||
this.but_open.prop('disabled', !access.read || !this._position);
|
||||
@@ -3186,7 +3187,8 @@ function eval_pyson(value){
|
||||
},
|
||||
remove: function(event_) {
|
||||
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
|
||||
if (!access.write || !access.read) {
|
||||
var writable = !this.screen.readonly;
|
||||
if (!access.write || !access.read || !writable) {
|
||||
return;
|
||||
}
|
||||
this.screen.remove(false, true, false);
|
||||
@@ -3301,7 +3303,8 @@ function eval_pyson(value){
|
||||
return this.edit();
|
||||
},
|
||||
delete_: function(event_) {
|
||||
if (!Sao.common.MODELACCESS.get(this.screen.model_name)['delete']) {
|
||||
if (!Sao.common.MODELACCESS.get(this.screen.model_name)['delete'] ||
|
||||
!this.screen.deletable) {
|
||||
return;
|
||||
}
|
||||
this.screen.remove(false, false, false);
|
||||
|
||||
+3
-2
@@ -303,7 +303,8 @@
|
||||
record_label: function(data) {
|
||||
var name = '_';
|
||||
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
|
||||
var readonly = this.screen.group.readonly;
|
||||
var deletable = this.screen.deletable;
|
||||
var readonly = this.screen.group.readonly || this.screen.readonly;
|
||||
if (data[0] >= 1) {
|
||||
name = data[0];
|
||||
if (this.domain) {
|
||||
@@ -311,7 +312,7 @@
|
||||
}
|
||||
this.but_next.prop('disabled', data[0] >= data[1]);
|
||||
this.but_previous.prop('disabled', data[0] <= 1);
|
||||
if (access.delete && !readonly) {
|
||||
if (access.delete && !readonly && deletable) {
|
||||
this.but_del.prop('disabled', false);
|
||||
this.but_undel.prop('disabled', false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user