Skip to Content
Menu
This question has been flagged
1159 Zobrazenia

Hello,

I am working on a custom addon in Odoo and I need to override a specific line in a core JavaScript file. The file I am referring to is located in the Odoo web client (start.js file) and contains the following code:

/** @odoo-module **/


import { makeEnv, startServices } from "./env";

import { legacySetupProm } from "./legacy/legacy_setup";

import { mapLegacyEnvToWowlEnv } from "./legacy/utils";

import { processTemplates } from "./core/assets";

import { session } from "@web/session";


const { mount, utils } = owl;

const { whenReady } = utils;


/**

* Function to start a webclient.

* It is used both in community and enterprise in main.js.

* It's meant to be webclient flexible so we can have a subclass of

* webclient in enterprise with added features.

*

* @param {owl.Component} Webclient

*/

export async function startWebClient(Webclient) {

    odoo.info = {

        db: session.db,

        server_version: session.db_version,

        server_version_info: session.server_version_info,

        isEnterprise: session.server_version_info.slice(-1)[0] === "e",

    };

    odoo.isReady = false;


    // setup environment

    const env = makeEnv();

    const [, templates] = await Promise.all([

        startServices(env),

        odoo.loadTemplatesPromise.then(processTemplates),

    ]);

    env.qweb.addTemplates(templates);


    // start web client

    await whenReady();

    const legacyEnv = await legacySetupProm;

    mapLegacyEnvToWowlEnv(legacyEnv, env);

    const root = await mount(Webclient, { env, target: document.body, position: "self" });

    // delete odoo.debug; // FIXME: some legacy code rely on this

    odoo.__WOWL_DEBUG__ = { root };

    odoo.isReady = true;


    // Update Favicons

    const favicon = `/web/image/res.company/${env.services.company.currentCompany.id}/favicon`;

    const icons = document.querySelectorAll("link[rel*='icon']");

    const msIcon = document.querySelector("meta[name='msapplication-TileImage']");

    for (const icon of icons) {

        icon.href = favicon;

    }

    if (msIcon) {

        msIcon.content = favicon;

    }

}


Specifically, I want to change the following line in my custom addon:
const favicon = `/web/image/res.company/${env.services.company.currentCompany.id}/favicon`;

to : 
const favicon = (static path to a favicon.ico)


I understand that directly modifying core files is not recommended, so I am looking for a way to achieve this through a custom addon. Could someone guide me on how to properly override or extend this specific line in my custom addon?

Thank you in advance for your help!

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
feb 24
1339
1
máj 19
4256
3
mar 15
20442
0
aug 24
3857
2
máj 23
6949