[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) <aab@odoo.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user