diff --git a/addons/website/__init__.py b/addons/website/__init__.py index b049931d218..50361e5b169 100644 --- a/addons/website/__init__.py +++ b/addons/website/__init__.py @@ -11,6 +11,14 @@ 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: