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 b6ea1d5c95a..c94980d45fc 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -604,7 +604,7 @@ var ListController = BasicController.extend({ _toggleCreateButton: function () { if (this.hasButtons) { var state = this.model.get(this.handle); - var createHidden = this.renderer.isEditable() && state.groupedBy.length && state.data.length; + var createHidden = this.editable && state.groupedBy.length && state.data.length; this.$buttons.find('.o_list_button_add').toggleClass('o_hidden', !!createHidden); } }, diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index d4c503c6cc0..96cdd85a33d 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -9090,6 +9090,44 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('control panel buttons in multi editable grouped list views', async function (assert) { + assert.expect(8); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + groupBy: ['foo'], + arch: + ` + + + `, + }); + + assert.containsNone(list, '.o_data_row', "all groups should be closed"); + assert.isVisible(list.$buttons.find('.o_list_button_add'), + "should have a visible Create button"); + + await testUtils.dom.click(list.$('.o_group_header:first')); + assert.containsN(list, '.o_data_row', 1, "first group should be opened"); + assert.isVisible(list.$buttons.find('.o_list_button_add'), + "should have a visible Create button"); + + await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_list_record_selector input')); + assert.containsOnce(list, '.o_data_row:eq(0) .o_list_record_selector input:enabled', + "should have selected first record"); + assert.isVisible(list.$buttons.find('.o_list_button_add'), + "should have a visible Create button"); + + await testUtils.dom.click(list.$('.o_group_header:last')); + assert.containsN(list, '.o_data_row', 2, "two groups should be opened"); + assert.isVisible(list.$buttons.find('.o_list_button_add'), + "should have a visible Create button"); + + list.destroy(); + }); + QUnit.test('edit a line and discard it in grouped editable', async function (assert) { assert.expect(5);