[IMP] website: use dedicated templates in configurator

This commit adapts the configurator so that the pages it generates are
composed of the primary templates generated from the manifest by the
previous commit.

task-3381714

Part-of: odoo/odoo#126719
This commit is contained in:
Benoit Socias
2023-10-14 03:27:03 +00:00
committed by Romain Derie
parent a2f8e18b76
commit 928eeca714
3 changed files with 9 additions and 2 deletions
@@ -231,6 +231,7 @@ class IrModuleModule(models.Model):
for module in self:
_logger.info('Load theme %s for website %s from template.' % (module.mapped('name'), website.id))
module._generate_primary_snippet_templates()
for model_name in self._theme_model_names:
module._update_records(model_name, website)
@@ -442,6 +443,7 @@ class IrModuleModule(models.Model):
], order='name')
for theme in themes:
theme._generate_primary_snippet_templates()
terp = self.get_module_info(theme.name)
images = terp.get('images', [])
for image in images:
+3 -2
View File
@@ -427,6 +427,7 @@ class Website(models.Model):
website = self.get_current_website()
theme_name = kwargs['theme_name']
theme = self.env['ir.module.module'].search([('name', '=', theme_name)])
theme._generate_primary_snippet_templates()
redirect_url = theme.button_choose_theme()
# Force to refresh env after install of module
@@ -614,7 +615,7 @@ class Website(models.Model):
for page_code in requested_pages - {'privacy_policy'}:
snippet_list = snippet_lists.get(page_code, [])
for snippet in snippet_list:
render, placeholders = _render_snippet(f'website.{snippet}')
render, placeholders = _render_snippet(f'website.configurator_{page_code}_{snippet}')
for placeholder in placeholders:
generated_content[placeholder] = ''
try:
@@ -642,7 +643,7 @@ class Website(models.Model):
nb_snippets = len(snippet_list)
for i, snippet in enumerate(snippet_list, start=1):
try:
render, placeholders = _render_snippet(f'website.{snippet}')
render, placeholders = _render_snippet(f'website.configurator_{page_code}_{snippet}')
# Fill rendered block with AI text
render = xml_translate(
+4
View File
@@ -8,6 +8,7 @@ from itertools import zip_longest
from lxml import etree as ET, html
from lxml.html import builder as h
from odoo.modules.module import _DEFAULT_MANIFEST, get_manifest
from odoo.tests import common, HttpCase, tagged
@@ -1510,6 +1511,9 @@ class TestThemeViews(common.TransactionCase):
# 2. Simulate a theme install with a child view of `main_view`
test_theme_module = self.env['ir.module.module'].create({'name': 'test_theme'})
# Themes are required to have a valid manifest, including a `new_page_templates` property.
# This theme is created in python and therefore has no manifest.
get_manifest('test_theme').update(_DEFAULT_MANIFEST)
self.env['ir.model.data'].create({
'module': 'base',
'name': 'module_test_theme_module',