From 6ca723dee41850d5caff76dd26016f166c04cb32 Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Wed, 29 Mar 2023 10:21:17 +0000 Subject: [PATCH] [FIX] web: group pager: use correct count Steps to reproduce ================== - Go to the products list view - Remove every filter/group by - Search for "bolt" - Group by > Add Custom Group > Active - Remove the bold filter - Expand the group Cause of the issue ================== The group pager is not displayed because the condition was incorrect A group pager should only be displayed when the group limit is less than the group count. The list count was used instead, meaning the total count was the number of groups and not the number of item in the group. opw-3221226 closes odoo/odoo#117267 X-original-commit: 4caab25d182bc2b5d1a2c315795a79d286a4491e Signed-off-by: Bruno Boi (boi) --- .../static/src/views/list/list_renderer.js | 4 +- .../web/static/tests/views/list_view_tests.js | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index 57a5b82e372..1070114dcc0 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -934,7 +934,7 @@ export class ListRenderer extends Component { return { offset: list.offset, limit: list.limit, - total: list.count, + total: group.count, onUpdate: async ({ offset, limit }) => { await list.load({ limit, offset }); this.render(true); @@ -1654,7 +1654,7 @@ export class ListRenderer extends Component { } showGroupPager(group) { - return !group.isFolded && group.list.limit < group.list.count; + return !group.isFolded && group.list.limit < group.count; } toggleGroup(group) { diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 5281a38d022..50dc15ae453 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -6091,6 +6091,51 @@ QUnit.module("Views", (hooks) => { } ); + QUnit.test( + "pager, grouped, group pager should update after removing a filter", + async function (assert) { + patchWithCleanup(DynamicRecordList, { WEB_SEARCH_READ_COUNT_LIMIT: 3 }); + serverData.models.foo.records = [ + { id: 121, foo: "aaa" }, + { id: 122, foo: "blip" }, + { id: 123, foo: "blip" }, + { id: 124, foo: "blip" }, + { id: 125, foo: "blip" }, + { id: 126, foo: "blip" }, + ]; + await makeView({ + type: "list", + resModel: "foo", + serverData, + arch: '', + searchViewArch: ` + + + + `, + }); + + await toggleFilterMenu(target); + await toggleMenuItem(target, "Foo"); + + await toggleGroupByMenu(target); + await toggleMenuItem(target, "Bar"); + + // expand group + await click(target, "th.o_group_name"); + + assert.containsNone(target, "th.o_group_name .o_pager_counter"); + + // remove filter + await removeFacet(target); + + assert.strictEqual( + $(target).find("th.o_group_name:eq(0) .o_pager_counter").text().trim(), + "1-2 / 6" + ); + } + ); + QUnit.test( "grouped, show only limited records when the list view is initially expanded", async function (assert) {