[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) <aab@odoo.com>
This commit is contained in:
Achraf (abz)
2021-01-29 11:56:03 +00:00
committed by Nasreddin (bon)
parent 638291128c
commit d70e1263f2
2 changed files with 39 additions and 1 deletions
@@ -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);
}
},
@@ -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:
`<tree multi_edit="1">
<field name="foo"/>
<field name="int_field"/>
</tree>`,
});
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);