diff --git a/addons/web/static/src/views/debug_items.js b/addons/web/static/src/views/debug_items.js index 0a37e9f64d3..d0455ac19d3 100644 --- a/addons/web/static/src/views/debug_items.js +++ b/addons/web/static/src/views/debug_items.js @@ -73,8 +73,14 @@ export function editSearchView({ accessRights, component, env }) { let { searchViewId } = component.props.info || {}; // fallback is there for legacy if ("viewParams" in component.props) { //legacy + if (!component.props.viewParams.action.controlPanelFieldsView) { + return null; + } searchViewId = component.props.viewParams.action.controlPanelFieldsView.view_id; } + if (searchViewId === undefined) { + return null; + } const description = env._t("Edit ControlPanelView"); return { type: "item", 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 70b7948f8d9..ed1ace59775 100644 --- a/addons/web/static/tests/core/debug/debug_manager_tests.js +++ b/addons/web/static/tests/core/debug/debug_manager_tests.js @@ -424,4 +424,29 @@ QUnit.module("DebugMenu", (hooks) => { "293" ); }); + + QUnit.test( + "cannot edit the control panel of a form view contained in a dialog without control panel.", + async (assert) => { + const mockRPC = async (route, args) => { + if (args.method === "check_access_rights") { + return Promise.resolve(true); + } + }; + prepareRegistriesWithCleanup(); + + patchWithCleanup(odoo, { + debug: true, + }); + registry.category("debug").category("view").add("editSearchViewItem", editSearchView); + + const serverData = getActionManagerServerData(); + + const webClient = await createWebClient({ serverData, mockRPC }); + // opens a form view in a dialog without a control panel. + await doAction(webClient, 5); + await click(webClient.el.querySelector(".o_dialog .o_debug_manager button")); + assert.containsNone(webClient, ".o_debug_manager .o_dropdown_item"); + } + ); });