[FIX] web: debug: allow to edit SearchView
Before this commit, clicking on "Edit ControlPanelView" in the debug manager actually edited the "main" view (e.g. kanban), because we used the wrong view id. This commit also renames "Edit ControlPanelView" into "Edit SearchView", which is more accurate w.r.t. to the view type. closes odoo/odoo#72995 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit is contained in:
@@ -416,16 +416,16 @@ export function editView({ accessRights, action, component, env }) {
|
||||
};
|
||||
}
|
||||
|
||||
function editControlPanelView({ accessRights, component, env }) {
|
||||
export function editSearchView({ accessRights, component, env }) {
|
||||
if (!accessRights.canEditView) {
|
||||
return null;
|
||||
}
|
||||
const description = env._t("Edit ControlPanelView");
|
||||
const description = env._t("Edit SearchView");
|
||||
return {
|
||||
type: "item",
|
||||
description,
|
||||
callback: () => {
|
||||
editModelDebug(env, description, "ir.ui.view", component.props.viewInfo.view_id);
|
||||
editModelDebug(env, description, "ir.ui.view", component.props.viewParams.controlPanelFieldsView.view_id);
|
||||
},
|
||||
sequence: 360,
|
||||
};
|
||||
@@ -516,7 +516,7 @@ debugRegistry
|
||||
.add("viewSeparator", viewSeparator)
|
||||
.add("fieldsViewGet", fieldsViewGet)
|
||||
.add("editView", editView)
|
||||
.add("editControlPanelView", editControlPanelView);
|
||||
.add("editSearchView", editSearchView);
|
||||
|
||||
debugRegistry
|
||||
.category("form")
|
||||
|
||||
@@ -15,7 +15,7 @@ import { makeFakeDialogService, makeFakeLocalizationService } from "../../helper
|
||||
import { click, getFixture, legacyExtraNextTick, patchWithCleanup } from "../../helpers/utils";
|
||||
import { createWebClient, doAction, getActionManagerServerData } from "../../webclient/helpers";
|
||||
import { openViewItem } from "@web/core/debug/debug_menu_items";
|
||||
import { editView } from "@web/legacy/debug_manager";
|
||||
import { editView, editSearchView } from "@web/legacy/debug_manager";
|
||||
|
||||
const { Component, hooks, mount, tags } = owl;
|
||||
const { useSubEnv } = hooks;
|
||||
@@ -340,4 +340,41 @@ QUnit.module("DebugMenu", (hooks) => {
|
||||
"18"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("can edit a search view", 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").add("editSearchViewItem", editSearchView);
|
||||
registry.category("services").add("debug", debugService);
|
||||
|
||||
const serverData = getActionManagerServerData();
|
||||
|
||||
serverData.views["partner,293,search"] = "<search></search>";
|
||||
serverData.actions[1].search_view_id = [293, "some_search_view"];
|
||||
serverData.models["ir.ui.view"] = {
|
||||
fields: {},
|
||||
records: [{ id: 293 }],
|
||||
};
|
||||
serverData.views["ir.ui.view,false,form"] = `<form><field name="id"/></form>`;
|
||||
|
||||
const webClient = await createWebClient({ serverData, mockRPC });
|
||||
await doAction(webClient, 1);
|
||||
await click(webClient.el.querySelector(".o_debug_manager button"));
|
||||
await click(webClient.el.querySelector(".o_debug_manager .o_dropdown_item"));
|
||||
await legacyExtraNextTick();
|
||||
assert.containsOnce(webClient, ".modal .o_form_view");
|
||||
assert.strictEqual(
|
||||
webClient.el.querySelector(".modal .o_form_view .o_field_widget[name=id]").value,
|
||||
"293"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user