[FIX] web: restore offset in grouped list

Issue:
Have a grouped list view with several pages, go to the next page,
open a group and click on a record to open it in form view. Click
on the breadcrumb to go back to the list: the offset is lost, and
we're back in page 1.

After this commit, the offset is correctly kept.

opw~3851390

closes odoo/odoo#162969

X-original-commit: 8dbf154fdbbff7790c99b3f91d3c1896d436a346
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2024-04-23 15:32:56 +00:00
parent f5d8b89bd7
commit 8981338ff2
@@ -7041,6 +7041,47 @@ QUnit.module("Views", (hooks) => {
}
);
QUnit.test("grouped list keeps offset on switchView", async (assert) => {
assert.expect(8);
serverData.views = {
"foo,false,search": `
<search>
<filter string="IntField" name="groupby" domain="[]" context="{'group_by': 'int_field'}"/>
</search>`,
"foo,99,list": `<list groups_limit="1"><field name="display_name" /></list>`,
"foo,100,form": `<form><field name="display_name" /></form>`,
};
const offsets = [0, 1, 1];
const mockRPC = async (route, args) => {
if (args.method === "web_read_group") {
assert.strictEqual(args.kwargs.offset, offsets.shift());
}
};
const wc = await createWebClient({ serverData, mockRPC });
await doAction(wc, {
res_model: "foo",
type: "ir.actions.act_window",
views: [
[99, "list"],
[100, "form"],
],
context: {
search_default_groupby: true,
},
});
assert.containsOnce(target, ".o_list_view");
await click(target, ".o_pager_next");
assert.containsNone(target, ".o_data_row");
await click(target, ".o_group_header");
assert.containsOnce(target, ".o_data_row");
await click(target, ".o_data_cell");
assert.containsOnce(target, ".o_form_view");
await click(target, ".o_back_button");
assert.containsOnce(target, ".o_data_row");
});
QUnit.test("can sort records when clicking on header", async function (assert) {
serverData.models.foo.fields.foo.sortable = true;