From 97733eae50b89c380fdb0a2f1929ee6570577d7a Mon Sep 17 00:00:00 2001 From: "Francois (fge)" Date: Mon, 20 Sep 2021 12:14:29 +0000 Subject: [PATCH] [FIX] web: fix Edit ControlPanelView The debug item "Edit ControlPanelView" is only available if there is a control panel in the current view. closes odoo/odoo#76862 X-original-commit: 68cb8d23e2011ed359fc54f3deed6c84290d5c3b Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/views/debug_items.js | 6 +++++ .../tests/core/debug/debug_manager_tests.js | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) 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"); + } + ); });