[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) <aab@odoo.com> Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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: '<tree limit="2"><field name="foo"/><field name="bar"/></tree>',
|
||||
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 = {
|
||||
|
||||
Reference in New Issue
Block a user