###To reproduce (V15): Video: https://drive.google.com/file/d/1wCebPCVQMXmQk7G4CIMkh1MbZ89HW9ek/view 1. Install the module "Product Availability" ("website_sale_stock") (that will install ecommerce & stock) 2. Choose a theme for the website (like developement) 3. Uninstall website => Internal server error ``` Exception: Unallowed to fetch files from addon website Error when render the template Exception: Unallowed to fetch files from addon website Template: web.frontend_layout Path: /t/html/head/t[1] Node: <t t-call-assets="web.assets_common" t-js="false"/> - - - ``` ###Analysis: The assets and view should in theory be deleted in cascade when the websites records are uninstalled. However, if a website record fails to be removed, for instance - in this case - because of pricelist which have an `ondelete=restrict` PSQL constraint on its `website_id` field. The PSQL cascade constraints on the other record are dropped before being applied which result in the resource being still there but not usable. Note: this issue is not specific to the website app in particular. It's just not worth to think for a more sophisticated way to fix this issue in a stable version. OPW-2700476 closes odoo/odoo#85443 X-original-commit: ef5296ab32426422698b763c33b2ddb5d0da6cc6 Signed-off-by: Romain Derie (rde) <rde@odoo.com>
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
# -*- encoding: utf-8 -*-
|
|
# 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 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()
|