[FIX] web: legacy list switches view to form with the right resIds
Have a legacy list view, click on a record to open it in a new (WOWL) form view Before this commit, the pager was wrong, as we never passed the list's current resIds to the form. After this commit, the pager of the wowl form view is correct. closes odoo/odoo#96123 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -381,7 +381,11 @@ export class ViewAdapter extends ActionAdapter {
|
||||
if (ev.name === "switch_view") {
|
||||
if (payload.view_type === "form") {
|
||||
if (payload.res_id) {
|
||||
return this.props.selectRecord(payload.res_id, { mode: payload.mode });
|
||||
const activeIds = this.__widget.model.get(this.__widget.handle).res_ids;
|
||||
return this.props.selectRecord(payload.res_id, {
|
||||
mode: payload.mode,
|
||||
activeIds,
|
||||
});
|
||||
} else {
|
||||
return this.props.createRecord();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ClientActionAdapter, ViewAdapter } from "@web/legacy/action_adapters";
|
||||
import { makeLegacyCrashManagerService } from "@web/legacy/utils";
|
||||
import { useDebugCategory } from "@web/core/debug/debug_context";
|
||||
import { ErrorDialog } from "@web/core/errors/error_dialogs";
|
||||
import * as cpHelpers from "@web/../tests/search/helpers";
|
||||
|
||||
import AbstractView from "web.AbstractView";
|
||||
import ControlPanel from "web.ControlPanel";
|
||||
@@ -742,4 +743,34 @@ QUnit.module("ActionManager", (hooks) => {
|
||||
await legacyExtraNextTick();
|
||||
assert.containsOnce(target, ".o_legacy_form_view");
|
||||
});
|
||||
|
||||
QUnit.test("correct pager when coming from list (legacy)", async (assert) => {
|
||||
assert.expect(4);
|
||||
|
||||
registry.category("views").remove("list");
|
||||
legacyViewRegistry.add("list", ListView);
|
||||
serverData.views = {
|
||||
"partner,false,search": `<search />`,
|
||||
"partner,99,list": `<list limit="4"><field name="display_name" /></list>`,
|
||||
"partner,100,form": `<form><field name="display_name" /></form>`,
|
||||
};
|
||||
|
||||
const wc = await createWebClient({ serverData });
|
||||
await doAction(wc, {
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [
|
||||
[99, "list"],
|
||||
[100, "form"],
|
||||
],
|
||||
});
|
||||
|
||||
assert.deepEqual(cpHelpers.getPagerValue(target), [1, 4]);
|
||||
assert.deepEqual(cpHelpers.getPagerLimit(target), 5);
|
||||
|
||||
await click(target, ".o_data_row:nth-child(2) .o_data_cell");
|
||||
await legacyExtraNextTick();
|
||||
assert.deepEqual(cpHelpers.getPagerValue(target), [2]);
|
||||
assert.deepEqual(cpHelpers.getPagerLimit(target), 4);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user