[FIX] web: doAction supports controllerState passed in option
In legacy, doAction can be passed the `controllerState` key, which contains `searchModel` and `searchPanel`, that an AbstractController can export. This commit re-implements this in the action service.
This commit is contained in:
committed by
Aaron Bohy
parent
8a888bca8a
commit
2aca56f0f0
@@ -670,6 +670,14 @@ function makeActionManager(env) {
|
||||
if (options.resId) {
|
||||
viewOptions.recordId = options.resId;
|
||||
}
|
||||
if (options.controllerState) {
|
||||
if (options.controllerState.searchModel) {
|
||||
viewOptions.searchModel = options.controllerState.searchModel;
|
||||
}
|
||||
if (options.controllerState.searchPanel) {
|
||||
viewOptions.searchPanel = options.controllerState.searchPanel;
|
||||
}
|
||||
}
|
||||
const controller = {
|
||||
jsId: `controller_${++id}`,
|
||||
Component: view,
|
||||
|
||||
@@ -10,7 +10,6 @@ import FormView from "web.FormView";
|
||||
import ListController from "web.ListController";
|
||||
import testUtils from "web.test_utils";
|
||||
import legacyViewRegistry from "web.view_registry";
|
||||
import { clearRegistryWithCleanup } from "../../helpers/mock_env";
|
||||
import { click, legacyExtraNextTick, nextTick, patchWithCleanup } from "../../helpers/utils";
|
||||
import { createWebClient, doAction, getActionManagerServerData, loadState } from "./../helpers";
|
||||
|
||||
@@ -2275,4 +2274,24 @@ QUnit.module("ActionManager", (hooks) => {
|
||||
"read_group", // read_group at reload after switch view
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"doAction supports being passed controlletState (searchModel)",
|
||||
async function (assert) {
|
||||
assert.expect(1);
|
||||
const mockRPC = async (route, args) => {
|
||||
if (route === "/web/dataset/search_read") {
|
||||
assert.deepEqual(args.domain, [["id", "=", 99]]);
|
||||
}
|
||||
};
|
||||
|
||||
const webClient = await createWebClient({ serverData, mockRPC });
|
||||
await doAction(webClient, 1, {
|
||||
controllerState: {
|
||||
searchModel:
|
||||
'{"ControlPanelModelExtension":{"filters":{"1":{"type":"field","description":"Foo","fieldName":"foo","fieldType":"char","groupId":1,"id":1},"2":{"description":"ID is \\"99\\"","domain":"[[\\"id\\",\\"=\\",99]]","type":"filter","groupId":3,"groupNumber":2,"id":2}},"query":[{"groupId":3,"filterId":2}]}}',
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user