From d70e1263f225d6125cbde19b1965c907b1bfef31 Mon Sep 17 00:00:00 2001 From: "Achraf (abz)" Date: Wed, 6 Jan 2021 10:14:05 +0000 Subject: [PATCH] [FIX] web: Show create button on multiEdit + unit test What are the steps to reproduce your issue ? 1. Install project 2. Open any project 3. Switch to list view and display by Stage 4. Open categoryA and select some records 5. Open CategoryB What is currently happening ? The button create is not displayed What are you expecting to happen ? Don't hide create button opw-2423701 closes odoo/odoo#65266 X-original-commit: 813b9fc42f5d0cc4e35afb642291200b90d1f545 Signed-off-by: Aaron Bohy (aab) --- .../src/js/views/list/list_controller.js | 2 +- addons/web/static/tests/views/list_tests.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) 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);