diff --git a/addons/web/static/src/js/views/abstract_view.js b/addons/web/static/src/js/views/abstract_view.js index 75de2be9446..5921c1b4bc3 100644 --- a/addons/web/static/src/js/views/abstract_view.js +++ b/addons/web/static/src/js/views/abstract_view.js @@ -105,7 +105,7 @@ var AbstractView = Factory.extend({ this.arch = this.fieldsView.arch; this.fields = this.fieldsView.viewFields; this.userContext = params.userContext || {}; - this.withControlPanel = params.withControlPanel; + this.withControlPanel = this.withControlPanel && params.withControlPanel; // the boolean parameter 'isEmbedded' determines if the view should be // considered as a subview. For now this is only used by the graph diff --git a/addons/web/static/src/js/views/form/form_view.js b/addons/web/static/src/js/views/form/form_view.js index d49f2b005fa..249f4ec6019 100644 --- a/addons/web/static/src/js/views/form/form_view.js +++ b/addons/web/static/src/js/views/form/form_view.js @@ -26,13 +26,20 @@ var FormView = BasicView.extend({ * @override */ init: function (viewInfo, params) { + var hasSidebar = params.hasSidebar; this._super.apply(this, arguments); var mode = params.mode || (params.currentId ? 'readonly' : 'edit'); this.loadParams.type = 'record'; + // this is kind of strange, but the param object is modified by + // AbstractView, so we only need to use its hasSidebar value if it was + // not already present in the beginning of this method + if (hasSidebar === undefined) { + hasSidebar = params.hasSidebar; + } + this.controllerParams.hasSidebar = hasSidebar; this.controllerParams.disableAutofocus = params.disable_autofocus; - this.controllerParams.hasSidebar = params.hasSidebar; this.controllerParams.toolbarActions = viewInfo.toolbar; this.controllerParams.footerToButtons = params.footerToButtons; @@ -63,7 +70,6 @@ var FormView = BasicView.extend({ /** * @override - * @param {string} [action.target] */ _extractParamsFromAction: function (action) { var params = this._super.apply(this, arguments); @@ -73,6 +79,7 @@ var FormView = BasicView.extend({ params.withControlPanel = !(inDialog || inline); params.footerToButtons = inDialog; params.hasSearchView = inDialog ? false : params.hasSearchView; + params.hasSidebar = !inDialog && !inline; params.searchMenuTypes = inDialog ? [] : params.searchMenuTypes; if (inDialog || inline || fullscreen) { params.mode = 'edit'; 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 291cb8de8a0..3b64e7b7714 100644 --- a/addons/web/static/src/js/views/list/list_view.js +++ b/addons/web/static/src/js/views/list/list_view.js @@ -57,8 +57,18 @@ var ListView = BasicView.extend({ //-------------------------------------------------------------------------- // Private - //--- + //-------------------------------------------------------------------------- + /** + * @override + */ + _extractParamsFromAction: function (action) { + var params = this._super.apply(this, arguments); + var inDialog = action.target === 'new'; + var inline = action.target === 'inline'; + params.hasSidebar = !inDialog && !inline; + return params; + }, _updateMVCParams: function () { this._super.apply(this, arguments); this.controllerParams.noLeaf = !!this.loadParams.context.group_by_no_leaf; diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 5a01abb14e6..6c0b0d96703 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -2126,6 +2126,22 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test('sidebar is present in list view', function (assert) { + assert.expect(2); + + var actionManager = createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + }); + actionManager.doAction(3); + + assert.isNotVisible(actionManager.$('.o_cp_sidebar button.o_dropdown_toggler_btn:contains("Action")')); + testUtils.dom.clickFirst(actionManager.$('input.custom-control-input')); + assert.isVisible(actionManager.$('.o_cp_sidebar button.o_dropdown_toggler_btn:contains("Action")')); + actionManager.destroy(); + }); + QUnit.test('can switch between views', function (assert) { assert.expect(18); diff --git a/addons/web/static/tests/helpers/test_utils_create.js b/addons/web/static/tests/helpers/test_utils_create.js index 0adb13d466f..5a64512260e 100644 --- a/addons/web/static/tests/helpers/test_utils_create.js +++ b/addons/web/static/tests/helpers/test_utils_create.js @@ -135,6 +135,7 @@ function createAsyncView(params) { currentId: 'res_id' in params ? params.res_id : undefined, domain: params.domain || [], context: params.context || {}, + hasSidebar: false, }); // patch the View to handle the groupBy given in params, as we can't give it // in init (unlike the domain and context which can be set in the action) diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js index c398e9df09f..814cf7f5173 100644 --- a/addons/web/static/tests/views/kanban_tests.js +++ b/addons/web/static/tests/views/kanban_tests.js @@ -465,7 +465,7 @@ QUnit.module('Views', { }); QUnit.test('quick create record with quick_create_view', function (assert) { - assert.expect(17); + assert.expect(19); var kanban = createView({ View: KanbanView, @@ -497,6 +497,7 @@ QUnit.module('Views', { }, }); + assert.containsOnce(kanban, '.o_cp_controller', 'should have one control panel'); assert.containsOnce(kanban, '.o_kanban_group:first .o_kanban_record', "first column should contain one record"); @@ -508,6 +509,7 @@ QUnit.module('Views', { "should have a quick create element in the first column"); assert.strictEqual($quickCreate.find('.o_form_view.o_xxs_form_view').length, 1, "should have rendered an XXS form view"); + assert.containsOnce(kanban, '.o_cp_controller', 'should not have instantiated an extra control panel'); assert.strictEqual($quickCreate.find('input').length, 2, "should have two inputs"); assert.strictEqual($quickCreate.find('.o_field_widget').length, 3,