How to change the title of odoo in odoo15 without editing the source code

Viewed 25

I want to change the title of odoo in the browser tag, but for some reason, I cannot change the source code. I found the code where to set the title in webclient.js but I don't know how to use it in my code.

    /** @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");
            }
        });
        .......
1 Answers

You need to patch the web client component class method

when one wishes to patch a standard method from a class, then we actually need to patch the prototype

Example:

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


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