如何在不编辑源代码的情况下更改odoo15中odoo的标题



我想更改浏览器标记中odoo的标题,但由于某种原因,我无法更改源代码。我在webclient.js中找到了设置标题的代码,但我不知道如何在代码中使用它。

/** @odoo-module **/
import { ActionContainer } from "./actions/action_container";
import { NavBar } from "./navbar/navbar";
import { useBus, useEffect, useService } from "@web/core/utils/hooks";
import { useTooltip } from "@web/core/tooltip/tooltip_hook";
import { NotUpdatable } from "../core/utils/components";
import { MainComponentsContainer } from "../core/main_components_container";
import { useOwnDebugContext } from "../core/debug/debug_context";
import { registry } from "@web/core/registry";
import { DebugMenu } from "@web/core/debug/debug_menu";
import { localization } from "@web/core/l10n/localization";
const { Component, hooks } = owl;
const { useExternalListener } = hooks;
export class WebClient extends Component {
setup() {
this.menuService = useService("menu");
this.actionService = useService("action");
this.title = useService("title");
this.router = useService("router");
this.user = useService("user");
useService("legacy_service_provider");
useOwnDebugContext({ categories: ["default"] });
if (this.env.debug) {
registry.category("systray").add(
"web.debug_mode_menu",
{
Component: DebugMenu,
},
{ sequence: 100 }
);
}
this.localization = localization;
this.title.setParts({ zopenerp: "Odoo" }); // zopenerp is easy to grep
useBus(this.env.bus, "ROUTE_CHANGE", this.loadRouterState);
useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", (mode) => {
if (mode !== "new") {
this.el.classList.toggle("o_fullscreen", mode === "fullscreen");
}
});
.......

您需要修补web客户端组件类方法

当希望从类中修补标准方法时,我们实际上需要修补prototype

示例:

import { WebClient } from "@web/webclient/webclient"
import {patch} from "web.utils";

patch(WebClient.prototype, "title patch", {
setup() {
this._super();
this.title.setParts({ zopenerp: "" });
},
});

最新更新