[FIX] web: kanban: missing quickcreate button in empty kanban
This commit fixes an issue where the quickcreate button was missing from the kanban view when it was grouped by a non many2one field and contained no record yet (so that no column is shown yet). Steps to reproduce: -Go to a kanban view on a model with no record -Group by as scalar value (eg: Description) ->The "New" button disappears OPW-3459808 closes odoo/odoo#143793 X-original-commit: 112ba1cb64b5170fdefd267de8e765f87b444b56 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Signed-off-by: Julien Carion (juca) <juca@odoo.com>
This commit is contained in:
@@ -249,7 +249,13 @@ export class KanbanController extends Component {
|
||||
if (!create) {
|
||||
return false;
|
||||
}
|
||||
return list.isGrouped ? list.groups.length > 0 || !createGroup : true;
|
||||
if (list.isGrouped) {
|
||||
if (list.groupByField.type !== "many2one") {
|
||||
return true;
|
||||
}
|
||||
return list.groups.length || !createGroup;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
get canQuickCreate() {
|
||||
|
||||
@@ -592,6 +592,35 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.verifySteps(["rendered"]);
|
||||
});
|
||||
|
||||
QUnit.test("basic grouped rendering with no record", async (assert) => {
|
||||
serverData.models.partner.records = [];
|
||||
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban class="o_kanban_test">
|
||||
<field name="bar" />
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="foo" />
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`,
|
||||
groupBy: ["bar"],
|
||||
});
|
||||
assert.containsOnce(target, ".o_kanban_grouped");
|
||||
assert.containsOnce(target, ".o_view_nocontent");
|
||||
assert.containsOnce(
|
||||
target,
|
||||
".o_control_panel_main_buttons .d-none.d-xl-inline-flex button.o-kanban-button-new",
|
||||
"There should be a 'New' button even though there is no column when groupby is not a many2one"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"basic grouped rendering with active field (archivable by default)",
|
||||
async (assert) => {
|
||||
|
||||
Reference in New Issue
Block a user