import json import logging import psycopg2 import threading import re from odoo import tools, api, fields, models, _ from odoo.addons.base.models.ir_http import _logger, FasterRule, IrHttp from odoo.addons.base.models.assetsbundle import JavascriptAsset from odoo.http import request, ROUTING_KEYS from odoo.tools.misc import submap from odoo.modules.registry import Registry from odoo.tools.js_transpiler import transpile_javascript from odoo.tools import config as odoo_config import odoo import odoo.exceptions import odoo.modules.registry import werkzeug.utils import werkzeug.routing import werkzeug.exceptions import werkzeug # Global variable for base URL replacement base_sorturl = [''] class IrConfigParameter(models.Model): _inherit = "ir.config_parameter" def write(self, vals): result = super(IrConfigParameter, self).write(vals) if result and any(rec.key == 'web.base.sorturl' for rec in self): # Clear routing cache properly for Odoo 19 self.env['ir.http'].env.registry.clear_cache("routing") # Regenerate assets bundles self.env['ir.attachment'].regenerate_assets_bundles() # Return proper action for client reload return {'type': 'ir.actions.client', 'tag': 'reload'} return result # ✅ Override JavascriptAsset.content property - Odoo 19 compatible @property def content(self): content = super(JavascriptAsset, self).content replacement = base_sorturl[0] or '' if self.name == "/web/static/src/core/browser/router.js": content = re.sub(r'(?