[FIX] web: list/kanban: remove count limit if total clicked
Commit [1] adds a limit on the search_count done to get the total
number of records matching the domain in a list or kanban view
(displayed in the pager).
When the limit is reached (10000), a `10000+` is displayed as
total. Clicking on it performs a search_count to get the actual
number of records.
Before this commit, from that point, the count limit was set to the
total number of records. It means that if a record was created or
modified to match the domain in the meantime, and the user clicked
on the pager to see the next page (for instance), a `+` was again
displayed next to the previously fetched search_count, which looks
like a bug.
To prevent this from happening, this commit simply removes the
count limit once the user has clicked on the total.
[1] 6acfad2651
closes odoo/odoo#110348
X-original-commit: 9aab36bcfb682865b615c8fbbc107afeee3a24f4
Related: odoo/enterprise#36001
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
@@ -2016,7 +2016,7 @@ export class DynamicRecordList extends DynamicList {
|
||||
async fetchCount() {
|
||||
const keepLast = this.model.keepLast;
|
||||
this.count = await keepLast.add(this.model.orm.searchCount(this.resModel, this.domain));
|
||||
this.countLimit = this.count;
|
||||
this.countLimit = Number.MAX_SAFE_INTEGER;
|
||||
this.hasLimitedCount = false;
|
||||
this.model.notify();
|
||||
}
|
||||
@@ -2101,12 +2101,14 @@ export class DynamicRecordList extends DynamicList {
|
||||
limit: this.limit,
|
||||
offset: this.offset,
|
||||
order: orderByToString(this.orderBy),
|
||||
count_limit: this.countLimit + 1,
|
||||
context: {
|
||||
bin_size: true,
|
||||
...this.context,
|
||||
},
|
||||
};
|
||||
if (this.countLimit !== Number.MAX_SAFE_INTEGER) {
|
||||
kwargs.count_limit = this.countLimit + 1;
|
||||
}
|
||||
const { records: rawRecords, length } =
|
||||
this.data ||
|
||||
(await this.model.orm.webSearchRead(
|
||||
|
||||
@@ -5654,6 +5654,7 @@ QUnit.module("Views", (hooks) => {
|
||||
QUnit.test("pager, ungrouped, with count limit reached", async function (assert) {
|
||||
patchWithCleanup(DynamicRecordList, { WEB_SEARCH_READ_COUNT_LIMIT: 3 });
|
||||
|
||||
let expectedCountLimit = 4;
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
@@ -5661,6 +5662,9 @@ QUnit.module("Views", (hooks) => {
|
||||
arch: '<tree limit="2"><field name="foo"/><field name="bar"/></tree>',
|
||||
mockRPC(route, args) {
|
||||
assert.step(args.method);
|
||||
if (args.method === "web_search_read") {
|
||||
assert.strictEqual(args.kwargs.count_limit, expectedCountLimit);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5674,6 +5678,10 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.strictEqual(target.querySelector(".o_pager_value").innerText, "1-2");
|
||||
assert.strictEqual(target.querySelector(".o_pager_limit").innerText, "4");
|
||||
assert.verifySteps(["search_count"]);
|
||||
|
||||
expectedCountLimit = undefined;
|
||||
await click(target.querySelector(".o_pager_next"));
|
||||
assert.verifySteps(["web_search_read"]);
|
||||
});
|
||||
|
||||
QUnit.test("pager, ungrouped, with count equals count limit", async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user