39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import base64
|
|
from pathlib import Path
|
|
|
|
from odoo import api, SUPERUSER_ID
|
|
|
|
|
|
def post_init_hook(env_or_cr, registry=None):
|
|
if registry is not None:
|
|
env = api.Environment(env_or_cr, SUPERUSER_ID, {})
|
|
else:
|
|
env = env_or_cr
|
|
CorporateWebsiteSetup(env).run()
|
|
|
|
|
|
class CorporateWebsiteSetup:
|
|
def __init__(self, env):
|
|
self.env = env
|
|
|
|
def run(self):
|
|
self._brand_website()
|
|
self._hide_duplicate_home_menu()
|
|
|
|
def _brand_website(self):
|
|
website = self.env["website"].sudo().search([], limit=1)
|
|
if not website:
|
|
return
|
|
logo_path = Path(__file__).parent / "static" / "src" / "img" / "metatroncube-logo.png"
|
|
values = {
|
|
"name": "Metatroncube Workplace",
|
|
}
|
|
if logo_path.exists():
|
|
values["logo"] = base64.b64encode(logo_path.read_bytes())
|
|
website.write(values)
|
|
|
|
def _hide_duplicate_home_menu(self):
|
|
menu = self.env.ref("mcs_corporate_website.menu_home", raise_if_not_found=False)
|
|
if menu:
|
|
menu.sudo().write({"is_visible": False})
|