From 255eb4c99c04da47b03320f8a760e09f23f9454e Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Mon, 8 Jan 2024 11:36:10 +0100 Subject: [PATCH] [FIX] website, *: generate primary snippet templates for each theme *: theme_default Since [1] when installing a theme from the Website builder's Themes tab, if that theme used other snippets than the default ones in their configurator pages which were inherited, the import of the theme failed because the primary template was not generated before the import of the data files. This commit relies on each theme calling `_generate_primary_snippet_templates` before declaring templates that require them. In master, the early loading is removed altogether. See the changes in `theme_default` for the approach that was adopted through all themes. Steps to reproduce in master: - Start odoo-bin with `-i website`. - Edit home page. - Go to the "Theme" tab. - Click on "Switch Theme". - Pick "CORPORATE / Buzzy". => Fails because the `website.configurator_s_banner` template is not defined. [1]: https://github.com/odoo/odoo/commit/cfed4e391d11058b1b46417f0b630cdbc4070d7c task-3670496 closes odoo/odoo#148443 Related: odoo/design-themes#755 Signed-off-by: Romain Derie (rde) --- addons/theme_default/__manifest__.py | 3 +++ addons/theme_default/data/generate_primary_template.xml | 9 +++++++++ addons/website/models/ir_module_module.py | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 addons/theme_default/data/generate_primary_template.xml diff --git a/addons/theme_default/__manifest__.py b/addons/theme_default/__manifest__.py index cc864e7fea6..df5fc3e5a74 100644 --- a/addons/theme_default/__manifest__.py +++ b/addons/theme_default/__manifest__.py @@ -8,6 +8,9 @@ 'sequence': 1000, 'version': '1.0', 'depends': ['website'], + 'data': [ + 'data/generate_primary_template.xml', + ], 'images': [ 'static/description/cover.png', 'static/description/theme_default_screenshot.jpg', diff --git a/addons/theme_default/data/generate_primary_template.xml b/addons/theme_default/data/generate_primary_template.xml new file mode 100644 index 00000000000..c4e0dd328ad --- /dev/null +++ b/addons/theme_default/data/generate_primary_template.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 71bec4c325a..56eea99a3aa 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -442,8 +442,7 @@ class IrModuleModule(models.Model): ], order='name') for theme in themes: - # TODO In master, only generate templates for installed themes. - # if theme.state != 'uninstalled': + # TODO In master, remove this call. theme._generate_primary_snippet_templates() terp = self.get_module_info(theme.name) images = terp.get('images', [])