diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 8307022dd4d..2ad142a8ffb 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -325,6 +325,11 @@ class IrModuleModule(models.Model): :param website: ``website`` model for which the themes have to be removed """ + # _theme_remove is the entry point of any change of theme for a website + # (either removal or installation of a theme and its dependencies). In + # either case, we need to reset some default configuration before. + self.env['theme.utils'].with_context(website_id=website.id)._reset_default_config() + if not website.theme_id: return diff --git a/addons/website/models/theme_models.py b/addons/website/models/theme_models.py index f10dafcbe2c..181280e8616 100644 --- a/addons/website/models/theme_models.py +++ b/addons/website/models/theme_models.py @@ -153,6 +153,16 @@ class Theme(models.AbstractModel): _auto = False def _post_copy(self, mod): + # Call specific theme post copy + theme_post_copy = '_%s_post_copy' % mod.name + if hasattr(self, theme_post_copy): + _logger.info('Executing method %s' % theme_post_copy) + method = getattr(self, theme_post_copy) + return method(mod) + return False + + @api.model + def _reset_default_config(self): # Reinitialize some css customizations self.env['web_editor.assets'].make_scss_customization( '/website/static/src/scss/options/user_values.scss', @@ -179,14 +189,6 @@ class Theme(models.AbstractModel): self.disable_view('website.template_footer_logo_only') self.disable_view('website.template_footer_address_logo') - # Call specific theme post copy - theme_post_copy = '_%s_post_copy' % mod.name - if hasattr(self, theme_post_copy): - _logger.info('Executing method %s' % theme_post_copy) - method = getattr(self, theme_post_copy) - return method(mod) - return False - @api.model def _toggle_view(self, xml_id, active): obj = self.env.ref(xml_id)