# Copyright 2025-Today Criptomart # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) from odoo import fields from odoo import models ESKAERA_URL_PREFIX = "/eskaera" class Website(models.Model): _inherit = "website" eskaera_enabled = fields.Boolean( string="Eskaera Group Orders", default=True, help="Serve the Eskaera collaborative purchasing pages on this website. " "Turn it off on a website that only runs the regular shop: its " "/eskaera pages answer 404 and its Eskaera menu is hidden.", ) class WebsiteMenu(models.Model): _inherit = "website.menu" def _compute_visible(self): """Hide the Eskaera menu on websites that do not serve it. Hiding rather than deleting the menu keeps the entry (and any manual rename or reordering) around, so switching the feature back on restores it as it was. """ res = super()._compute_visible() for menu in self: if not menu.is_visible or not menu.website_id: continue if menu.website_id.eskaera_enabled: continue if (menu.url or "").startswith(ESKAERA_URL_PREFIX): menu.is_visible = False return res