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: '', + }); + + 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);