[FIX] website: update theme images also during updates

In order for preview images to be shown in the theme selection page, the
`update_theme_images` function needs to be called.
This was done in a `post_init_hook`, which is called e.g. when
installing `website`.
This was also done in a `website` override of
`ir.module.module.update_list()` which is called when updating a module
interactively.
Unfortunately, even though this override is defined, at the time
`update_list()` is called from `loading.py` when using `-u` in the
command line, the modules are not loaded yet, and therefore the override
is not applied.
Because of this, when a database was upgraded to versions that introduce
new themes or new screenshots for themes, `update_theme_images` was not
called during the upgrade, and the new images were missing in the
upgraded database.

This commit solves this by calling `update_theme_images` from a
`function` data record, so that it is run both on install and on update
of `website`.

Steps to reproduce:
- Install website and a theme in 14.0.
- Upgrade to 15.0.
- Access the theme selection page.

=> Images were missing for some themes.

task-2719425

X-original-commit: 8e73375e674ba0018ac4ea12a5b19bb4e6bcae31
Part-of: odoo/odoo#163118
This commit is contained in:
Benoit Socias
2024-04-25 17:06:49 +00:00
parent 195e0c8ddf
commit 46c889b946
3 changed files with 7 additions and 2 deletions
-2
View File
@@ -39,8 +39,6 @@ def uninstall_hook(env):
def post_init_hook(env):
env['ir.module.module'].update_theme_images()
if request:
env = env(context=request.default_context())
request.website_routing = env['website'].get_current_website().id
+2
View File
@@ -115,6 +115,8 @@
'views/neutralize_views.xml',
'wizard/base_language_install_views.xml',
'wizard/website_robots.xml',
# Replaces a post_init_hook that should be run on upgrade too.
'data/update_theme_images.xml',
],
'demo': [
'data/website_demo.xml',
@@ -0,0 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<function model="ir.module.module" name="update_theme_images">
</function>
</odoo>