[FIX] web: DebugManager: editView: correctly load view
Before this commit, the "Edit View" debug item only worked for kanban, list and form views. For the other views, it opened a blank form view. The reason is that for the other views, it didn't correctly get the id of the view to edit. Bug reported in the wowl-bugs pad closes odoo/odoo#72523 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import { formatDateTime, parseDateTime } from "../core/l10n/dates";
|
||||
import { _lt } from "../core/l10n/translation";
|
||||
import { registry } from "../core/registry";
|
||||
import { formatMany2one } from "../fields/format";
|
||||
import { json_node_to_xml } from "../views/view_utils";
|
||||
|
||||
const { hooks, tags } = owl;
|
||||
const { useState } = hooks;
|
||||
@@ -403,7 +402,8 @@ export function editView({ accessRights, action, component, env }) {
|
||||
if (!accessRights.canEditView) {
|
||||
return null;
|
||||
}
|
||||
const { viewId, viewType } = component.widget;
|
||||
let { view_id: viewId, type: viewType } = component.props.viewInfo;
|
||||
viewType = viewType === "tree" ? "list" : viewType;
|
||||
const displayName = action.views.find((v) => v.type === viewType).name.toString();
|
||||
const description = env._t("Edit View: ") + displayName;
|
||||
return {
|
||||
|
||||
@@ -13,8 +13,9 @@ import { registerCleanup } from "../../helpers/cleanup";
|
||||
import { makeTestEnv, prepareRegistriesWithCleanup } from "../../helpers/mock_env";
|
||||
import { makeFakeDialogService, makeFakeLocalizationService } from "../../helpers/mock_services";
|
||||
import { click, getFixture, legacyExtraNextTick, patchWithCleanup } from "../../helpers/utils";
|
||||
import { createWebClient, getActionManagerServerData } from "../../webclient/helpers";
|
||||
import { createWebClient, doAction, getActionManagerServerData } from "../../webclient/helpers";
|
||||
import { openViewItem } from "@web/core/debug/debug_menu_items";
|
||||
import { editView } from "@web/legacy/debug_manager";
|
||||
|
||||
const { Component, hooks, mount, tags } = owl;
|
||||
const { useSubEnv } = hooks;
|
||||
@@ -296,4 +297,47 @@ QUnit.module("DebugMenu", (hooks) => {
|
||||
assert.containsNone(webClient, ".modal");
|
||||
assert.containsOnce(webClient, ".some_view");
|
||||
});
|
||||
|
||||
QUnit.test("can edit a pivot 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("editViewItem", editView);
|
||||
registry.category("services").add("debug", debugService);
|
||||
|
||||
const serverData = getActionManagerServerData();
|
||||
serverData.actions[1234] = {
|
||||
id: 1234,
|
||||
xml_id: "action_1234",
|
||||
name: "Reporting Ponies",
|
||||
res_model: "pony",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[18, "pivot"]],
|
||||
};
|
||||
serverData.views["pony,18,pivot"] = "<pivot></pivot>";
|
||||
serverData.models["ir.ui.view"] = {
|
||||
fields: {},
|
||||
records: [{ id: 18 }],
|
||||
};
|
||||
serverData.views["ir.ui.view,false,form"] = `<form><field name="id"/></form>`;
|
||||
|
||||
const webClient = await createWebClient({ serverData, mockRPC });
|
||||
await doAction(webClient, 1234);
|
||||
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,
|
||||
"18"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -126,11 +126,11 @@ export class MockServer {
|
||||
if (!arch) {
|
||||
const genericViewKey = Object.keys(this.archs).find((fullKey) => {
|
||||
const [_model, _viewID, _viewType] = fullKey.split(",");
|
||||
viewId = parseInt(_viewID, 10);
|
||||
return _model === modelName && _viewType === viewType;
|
||||
});
|
||||
if (genericViewKey) {
|
||||
arch = this.archs[genericViewKey];
|
||||
viewId = parseInt(genericViewKey.split(",")[1], 10) || false;
|
||||
}
|
||||
}
|
||||
if (!arch) {
|
||||
|
||||
Reference in New Issue
Block a user