diff --git a/addons/web/static/src/views/view.js b/addons/web/static/src/views/view.js index 3af0cbfb574..6cf455024a4 100644 --- a/addons/web/static/src/views/view.js +++ b/addons/web/static/src/views/view.js @@ -162,6 +162,7 @@ export class View extends Component { view[0] = viewDescription.viewId; searchViewDescription = viewDescriptions.search; if (loadSearchView) { + searchViewId = searchViewId || searchViewDescription.viewId; if (!searchViewArch) { searchViewArch = searchViewDescription.arch; searchViewFields = searchViewDescription.fields; @@ -235,7 +236,7 @@ export class View extends Component { } } - // prepare the WithSearh component props + // prepare the WithSearch component props this.withSearchProps = { ...this.props, Component: ViewClass, diff --git a/addons/web/static/tests/core/debug/debug_manager_tests.js b/addons/web/static/tests/core/debug/debug_manager_tests.js index 48fd9eb55c1..ddd9c73e8e7 100644 --- a/addons/web/static/tests/core/debug/debug_manager_tests.js +++ b/addons/web/static/tests/core/debug/debug_manager_tests.js @@ -7,6 +7,7 @@ import { registry } from "@web/core/registry"; import { useDebugCategory, useOwnDebugContext } from "@web/core/debug/debug_context"; import { ormService } from "@web/core/orm_service"; import { uiService } from "@web/core/ui/ui_service"; +import { useSetupView } from "@web/views/helpers/view_hook"; import { ActionDialog } from "@web/webclient/actions/action_dialog"; import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { registerCleanup } from "../../helpers/cleanup"; @@ -417,6 +418,66 @@ QUnit.module("DebugMenu", (hooks) => { ); }); + QUnit.test("edit search view on action without search_view_id", async (assert) => { + // When the kanban view will be converted to Owl, this test could be simplified by + // removing the toy view and using the kanban view directly + prepareRegistriesWithCleanup(); + + class ToyView extends Component { + setup() { + useSetupView(); + } + } + ToyView.template = xml`
`; + ToyView.type = "toy"; + ToyView.display_name = "toy view"; + registry.category("views").add("toy", ToyView); + + const mockRPC = async (route, args) => { + if (args.method === "check_access_rights") { + return Promise.resolve(true); + } + }; + + patchWithCleanup(odoo, { + debug: true, + }); + + registry.category("debug").category("view").add("editSearchViewItem", editSearchView); + + const serverData = getActionManagerServerData(); + serverData.actions[1] = { + id: 1, + xml_id: "action_1", + name: "Partners Action 1", + res_model: "partner", + type: "ir.actions.act_window", + views: [[false, "toy"]], + search_view_id: false, + }; + serverData.models["ir.ui.view"] = { + fields: {}, + records: [{ id: 293 }], + }; + serverData.views = {}; + serverData.views["ir.ui.view,false,form"] = ``; + serverData.views["partner,false,toy"] = `