From 049fe6f9edf6538d655f47b2c38ebdbbeaa7429f Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 28 Aug 2023 11:39:25 +0200 Subject: [PATCH] [FIX] web: multi level grouped list: do not consider empty Before this commit, when a list view was grouped by more than 1 field, the view was considered empty, and the no content helper was displayed. For instance, go to Contacts and group by Company and Country. Part-of: odoo/odoo#133305 --- .../relational_model/dynamic_group_list.js | 3 --- .../static/src/model/relational_model/group.js | 2 +- .../web/static/tests/views/list_view_tests.js | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/model/relational_model/dynamic_group_list.js b/addons/web/static/src/model/relational_model/dynamic_group_list.js index 14344a30a8a..6d4d21cb77c 100644 --- a/addons/web/static/src/model/relational_model/dynamic_group_list.js +++ b/addons/web/static/src/model/relational_model/dynamic_group_list.js @@ -36,9 +36,6 @@ export class DynamicGroupList extends DynamicList { } get hasData() { - if (this.count === 0) { - return false; - } return this.groups.some((group) => group.hasData); } diff --git a/addons/web/static/src/model/relational_model/group.js b/addons/web/static/src/model/relational_model/group.js index 3fd33a1cc04..f874792d06e 100644 --- a/addons/web/static/src/model/relational_model/group.js +++ b/addons/web/static/src/model/relational_model/group.js @@ -42,7 +42,7 @@ export class Group extends DataPoint { // ------------------------------------------------------------------------- get hasData() { - return this.list.hasData; + return this.count > 0; } get isFolded() { return this.config.isFolded; diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index f755ea475e1..e301b6432b3 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -2195,6 +2195,24 @@ QUnit.module("Views", (hooks) => { ); }); + QUnit.test("list view with multiple groupbys", async function (assert) { + await makeView({ + type: "list", + resModel: "foo", + serverData, + arch: '', + groupBy: ["bar", "foo"], + noContentHelp: "

should not be displayed

", + }); + + assert.containsNone(target, ".o_view_nocontent"); + assert.containsN(target, ".o_group_has_content", 2); + assert.deepEqual(getNodesTextContent(target.querySelectorAll(".o_group_has_content")), [ + "No (1) ", + "Yes (3) ", + ]); + }); + QUnit.test("deletion of record is disabled when groupby m2m field", async function (assert) { serviceRegistry.add( "user",