summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2017-11-17 11:31:37 +0100
committerAlexandre Kühn <aku@odoo.com>2017-11-17 12:34:25 +0100
commit11ff01af9b3887e7ec70dae204cd0d2c1bc0f8f0 (patch)
tree68257737286e7691c997d1fe8b21cd877c9857dc /addons
parent76e75be02f3aa7fa1b965475f18e0f1c31fb910d (diff)
[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.
Diffstat (limited to 'addons')
-rw-r--r--addons/web/static/src/js/views/list/list_controller.js2
-rw-r--r--addons/web/static/src/js/views/list/list_view.js1
-rw-r--r--addons/web/static/tests/views/list_tests.js21
3 files changed, 22 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js
index 67cc6271509..5c6b7ea414d 100644
--- a/addons/web/static/src/js/views/list/list_controller.js
+++ b/addons/web/static/src/js/views/list/list_controller.js
@@ -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();
diff --git a/addons/web/static/src/js/views/list/list_view.js b/addons/web/static/src/js/views/list/list_view.js
index 61612282bf5..b2295affb98 100644
--- a/addons/web/static/src/js/views/list/list_view.js
+++ b/addons/web/static/src/js/views/list/list_view.js
@@ -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;
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index fc05a1c92a4..6156a218744 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -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);