# Part of Odoo. See LICENSE file for full copyright and licensing details. from . import controllers from . import models from . import wizard import odoo from odoo import api, SUPERUSER_ID from odoo.http import request from functools import partial def uninstall_hook(cr, registry): # Force remove ondelete='cascade' elements, # This might be prevented by another ondelete='restrict' field # TODO: This should be an Odoo generic fix, not a website specific one env = api.Environment(cr, SUPERUSER_ID, {}) website_domain = [('website_id', '!=', False)] env['ir.asset'].search(website_domain).unlink() env['ir.ui.view'].search(website_domain).with_context(active_test=False, _force_unlink=True).unlink() def rem_website_id_null(dbname): db_registry = odoo.modules.registry.Registry.new(dbname) with db_registry.cursor() as cr: env = api.Environment(cr, SUPERUSER_ID, {}) env['ir.model.fields'].search([ ('name', '=', 'website_id'), ('model', '=', 'res.config.settings'), ]).unlink() cr.postcommit.add(partial(rem_website_id_null, cr.dbname)) def post_init_hook(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) env['ir.module.module'].update_theme_images() if request: env = env(context=request.default_context()) request.website_routing = env['website'].get_current_website().id