2021-05-10 15:45:35 +02:00
|
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
|
|
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
|
|
|
2023-01-30 14:14:07 +00:00
|
|
|
def post_init_hook(env):
|
2021-05-10 15:45:35 +02:00
|
|
|
''' Create a new website for each theme and install the theme on it. '''
|
|
|
|
|
IrModule = env['ir.module.module']
|
2022-08-29 21:55:51 +00:00
|
|
|
themes = IrModule.search(IrModule.get_themes_domain(), order='name')
|
2021-05-10 15:45:35 +02:00
|
|
|
assert len(themes) == len(env.ref('base.module_test_themes').dependencies_id)
|
|
|
|
|
|
|
|
|
|
xmlids = []
|
|
|
|
|
for theme in themes:
|
|
|
|
|
website = env['website'].create({
|
|
|
|
|
'name': theme.display_name,
|
|
|
|
|
'theme_id': theme.id,
|
|
|
|
|
})
|
|
|
|
|
xmlids.append({
|
|
|
|
|
'xml_id': 'test_themes.%s' % theme.display_name.replace(' ', '_'),
|
|
|
|
|
'record': website,
|
|
|
|
|
'noupdate': True, # Avoid unlink on -u
|
|
|
|
|
})
|
2022-10-27 12:45:38 +00:00
|
|
|
theme.with_context(apply_new_theme=True)._theme_get_stream_themes()._theme_load(website)
|
2021-05-10 15:45:35 +02:00
|
|
|
env['ir.model.data']._update_xmlids(xmlids)
|