[FIX] web: delete attribute on list view
Before this fix, when adding the attribute delete=0 on a listview, it was still possible to delete records via the menu 'Delete' in the sidebar. After this fix, this should not be possible to delete records when delete=0. The attribute delete was hard-coded to true, as there was a traceback when it was set to false. It was simply due to a misplaced closing brackets that was hiding an assignment, which resulted to calling a method on undefined.
This commit is contained in:
@@ -148,6 +148,7 @@ var ListController = BasicController.extend({
|
||||
label: _t('Delete'),
|
||||
callback: this._onDeleteSelectedRecords.bind(this)
|
||||
});
|
||||
}
|
||||
this.sidebar = new Sidebar(this, {
|
||||
editable: this.is_action_enabled('edit'),
|
||||
env: {
|
||||
@@ -157,7 +158,6 @@ var ListController = BasicController.extend({
|
||||
},
|
||||
actions: _.extend(this.toolbarActions, {other: other}),
|
||||
});
|
||||
}
|
||||
this.sidebar.appendTo($node);
|
||||
|
||||
this._toggleSidebar();
|
||||
|
||||
@@ -42,7 +42,6 @@ var ListView = BasicView.extend({
|
||||
this.controllerParams.editable = arch.attrs.editable;
|
||||
this.controllerParams.hasSidebar = params.sidebar;
|
||||
this.controllerParams.toolbarActions = viewInfo.toolbar;
|
||||
this.controllerParams.activeActions.delete = true;
|
||||
this.controllerParams.noLeaf = !!this.loadParams.context.group_by_no_leaf;
|
||||
this.controllerParams.mode = mode;
|
||||
|
||||
|
||||
@@ -141,6 +141,27 @@ QUnit.module('Views', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('list with delete="0"', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
viewOptions: {sidebar: true},
|
||||
arch: '<tree delete="0"><field name="foo"/></tree>',
|
||||
});
|
||||
|
||||
assert.ok(list.sidebar.$el.hasClass('o_hidden'), 'sidebar should be invisible');
|
||||
assert.ok(list.$('tbody td.o_list_record_selector').length, "should have at least one record");
|
||||
|
||||
list.$('tbody td.o_list_record_selector:first input').click();
|
||||
assert.ok(!list.sidebar.$el.hasClass('o_hidden'), 'sidebar should be visible');
|
||||
assert.notOk(list.sidebar.$('a:contains(Delete)').length, 'sidebar should not have Delete button');
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('simple editable rendering', function (assert) {
|
||||
assert.expect(12);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user