From 065943aff360e7ccc3d0d1e3b694eba63a95bf09 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Thu, 27 Oct 2022 14:17:54 +0000 Subject: [PATCH] [FIX] web: group's count as the pager limit of grouped list **Issue:** When a group contains more than 10k items, its pager only shows 10k as limit, even if the group already knows it's total count. **Solution:** We now allow creation of `DynamicRecordList` with 'countLimit' as one of the params. It will be used in the instantiation of the class but will default to WEB_SEARCH_READ_COUNT_LIMIT if not provided. This way, pager's limit will be properly set to the group's count. closes odoo/odoo#104698 X-original-commit: 4751f85ac9d430528106de05bcdc484ae0c7079b Signed-off-by: Aaron Bohy (aab) Signed-off-by: Joseph Caburnay (jcb) --- .../web/static/src/views/relational_model.js | 3 +- .../web/static/tests/views/list_view_tests.js | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/relational_model.js b/addons/web/static/src/views/relational_model.js index 7c77789bcf3..a3cf7746cd2 100644 --- a/addons/web/static/src/views/relational_model.js +++ b/addons/web/static/src/views/relational_model.js @@ -1805,7 +1805,7 @@ export class DynamicRecordList extends DynamicList { /** @type {Record[]} */ this.records = []; this.data = params.data; - this.countLimit = this.constructor.WEB_SEARCH_READ_COUNT_LIMIT; + this.countLimit = params.countLimit || this.constructor.WEB_SEARCH_READ_COUNT_LIMIT; this.hasLimitedCount = false; } @@ -2569,6 +2569,7 @@ export class Group extends DataPoint { activeFields: params.activeFields, fields: params.fields, limit: params.limit, + countLimit: params.count, groupByInfo: params.groupByInfo, onCreateRecord: params.onCreateRecord, onRecordWillSwitchMode: params.onRecordWillSwitchMode, diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 179c2f3962b..3889b169606 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -5203,6 +5203,35 @@ QUnit.module("Views", (hooks) => { ); }); + QUnit.test( + "pager, grouped, pager limit should be based on the group's count", + async function (assert) { + patchWithCleanup(DynamicRecordList, { WEB_SEARCH_READ_COUNT_LIMIT: 3 }); + serverData.models.foo.records = [ + { id: 121, foo: "blip" }, + { 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: '', + groupBy: ["foo"], + }); + + // unfold + await click(target.querySelector(".o_group_header:first-of-type")); + assert.strictEqual( + target.querySelector(".o_group_header:first-of-type .o_pager_limit").innerText, + "6" + ); + } + ); + QUnit.test("list keeps offset on switchView", async (assert) => { assert.expect(3); serverData.views = {