diff --git a/website_odoo_debranding/__init__.py b/website_odoo_debranding/__init__.py index 4055855eb..a0c8625e6 100644 --- a/website_odoo_debranding/__init__.py +++ b/website_odoo_debranding/__init__.py @@ -1,3 +1,3 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). - +from . import models from .hooks import post_init_hook diff --git a/website_odoo_debranding/__manifest__.py b/website_odoo_debranding/__manifest__.py index ce5621f52..48ef9f7b2 100644 --- a/website_odoo_debranding/__manifest__.py +++ b/website_odoo_debranding/__manifest__.py @@ -9,6 +9,12 @@ "category": "Website", "depends": ["website"], "data": ["templates/disable_odoo.xml"], + "assets": { + "web.assets_backend": [ + "website_odoo_debranding/static/src/client_actions/configurator.esm.js", + "website_odoo_debranding/static/src/components/website_loader.esm.js", + ], + }, "installable": True, "post_init_hook": "post_init_hook", } diff --git a/website_odoo_debranding/models/__init__.py b/website_odoo_debranding/models/__init__.py new file mode 100644 index 000000000..bd190fa80 --- /dev/null +++ b/website_odoo_debranding/models/__init__.py @@ -0,0 +1 @@ +from . import website diff --git a/website_odoo_debranding/models/website.py b/website_odoo_debranding/models/website.py new file mode 100644 index 000000000..0a899c016 --- /dev/null +++ b/website_odoo_debranding/models/website.py @@ -0,0 +1,21 @@ +from odoo import api, models + + +class Website(models.Model): + _inherit = "website" + + @api.model + def get_website_logo_url(self): + website = self.get_current_website() + logo_url = False + if website: + logo_url = f"url('/website/image/website/{website.id}/logo')" + default_logo = website._default_logo() + uses_default_logo = not website.logo or website.logo == default_logo + if uses_default_logo: + if not website.company_id.uses_default_logo: + logo_url = ( + f"url('/website/image/res.company/" + f"{website.company_id.id}/logo')" + ) + return logo_url diff --git a/website_odoo_debranding/static/src/client_actions/configurator.esm.js b/website_odoo_debranding/static/src/client_actions/configurator.esm.js new file mode 100644 index 000000000..2a002fdf3 --- /dev/null +++ b/website_odoo_debranding/static/src/client_actions/configurator.esm.js @@ -0,0 +1,98 @@ +import { + Configurator,DescriptionScreen,FeaturesSelectionScreen,PaletteSelectionScreen,ThemeSelectionScreen,WelcomeScreen +} from "@website/client_actions/configurator/configurator"; +import {onMounted,onWillStart} from "@odoo/owl"; +import {patch} from "@web/core/utils/patch"; +import { useService } from "@web/core/utils/hooks"; + +patch(Configurator.prototype, { + setup() { + super.setup(); + onMounted(this.onMounted); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }) + }, + async onMounted() { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_configurator_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + } + +}); + +patch(WelcomeScreen.prototype, { + setup() { + super.setup(); + onMounted(this.onMounted); + this.orm = useService('orm'); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }) + }, + onMounted() { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_configurator_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + } +}); + +patch(DescriptionScreen.prototype, { + setup() { + super.setup(); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }) + }, + onMounted() { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_configurator_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + super.onMounted(); + } +}); + +patch(PaletteSelectionScreen.prototype, { + setup() { + super.setup(); + onMounted(this.onMounted); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }) + }, + onMounted() { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_configurator_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + } +}); + +patch(FeaturesSelectionScreen.prototype, { + setup() { + super.setup(); + onMounted(this.onMounted); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }) + }, + onMounted() { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_configurator_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + } +}); + +patch(ThemeSelectionScreen.prototype, { + setup() { + super.setup(); + onMounted(this.onMounted); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }) + }, + onMounted() { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_configurator_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + } +}); diff --git a/website_odoo_debranding/static/src/components/website_loader.esm.js b/website_odoo_debranding/static/src/components/website_loader.esm.js new file mode 100644 index 000000000..f996157a5 --- /dev/null +++ b/website_odoo_debranding/static/src/components/website_loader.esm.js @@ -0,0 +1,26 @@ +import {onWillStart,useEffect} from "@odoo/owl"; +import { + WebsiteLoader, +} from "@website/components/website_loader/website_loader"; +import {patch} from "@web/core/utils/patch"; +import { useService } from "@web/core/utils/hooks"; + +patch(WebsiteLoader.prototype, { + setup() { + super.setup(); + this.orm = useService('orm'); + onWillStart(async () => { + this.website_logo_url = await this.orm.call('website', 'get_website_logo_url') + }); + useEffect( + (isVisible) => { + if (isVisible) { + // eslint-disable-next-line no-undef + var htmlTag = document.getElementsByClassName("o_website_loader_odoo_logo"); + htmlTag[0].style.setProperty('--configurator-logo',this.website_logo_url); + } + }, + () => [this.state.isVisible] + ); + }, +});