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 dfa7d272a49..c8dd6a86771 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -376,8 +376,9 @@ var ListController = BasicController.extend({ * @returns {Deferred} */ _update: function () { - this._toggleSidebar(); - return this._super.apply(this, arguments); + return this._super.apply(this, arguments) + .then(this._toggleSidebar.bind(this)) + .then(this._updateButtons.bind(this, 'readonly')); }, /** * This helper simply makes sure that the control panel buttons matches the diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 18dd10c52a6..cf41de943ba 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -14,6 +14,7 @@ var testUtilsDom = require('web.test_utils_dom'); var widgetRegistry = require('web.widget_registry'); var Widget = require('web.Widget'); +var createActionManager = testUtils.createActionManager; var createView = testUtils.createView; QUnit.module('Views', { @@ -840,6 +841,47 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('editable list view: check that controlpanel buttons are updating when groupby applied', function (assert) { + assert.expect(4); + + this.data.foo.fields.foo = {string: "Foo", type: "char", required:true}; + + var actionManager = createActionManager({ + actions: [{ + id: 11, + name: 'Partners Action 11', + res_model: 'foo', + type: 'ir.actions.act_window', + views: [[3, 'list']], + search_view_id: [9, 'search'], + }], + archs: { + 'foo,3,list': '', + + 'foo,9,search': ''+ + '' + + '', + }, + data: this.data, + }); + + actionManager.doAction(11); + testUtils.dom.click(actionManager.$('.o_list_button_add')); + + assert.isNotVisible(actionManager.$('.o_list_button_add'), + "create button should be invisible"); + assert.isVisible(actionManager.$('.o_list_button_save'), "save button should be visible"); + + testUtils.dom.click(actionManager.$('.o_dropdown_toggler_btn:contains("Group By")')); + testUtils.dom.click(actionManager.$('.o_group_by_menu .o_menu_item a:contains("candle")')); + + assert.isVisible(actionManager.$('.o_list_button_add'), "create button should be invisible"); + assert.isNotVisible(actionManager.$('.o_list_button_save'), + "save button should be invisible after applying groupby"); + + actionManager.destroy(); + }); + QUnit.test('selection changes are triggered correctly', function (assert) { assert.expect(8);