From 46c889b94695b482bfdbf3fcd442e671028e414b Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Thu, 4 Apr 2024 09:57:01 +0200 Subject: [PATCH] [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 --- addons/website/__init__.py | 2 -- addons/website/__manifest__.py | 2 ++ addons/website/data/update_theme_images.xml | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 addons/website/data/update_theme_images.xml diff --git a/addons/website/__init__.py b/addons/website/__init__.py index 7d96f2f6742..70ad0464eac 100644 --- a/addons/website/__init__.py +++ b/addons/website/__init__.py @@ -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 diff --git a/addons/website/__manifest__.py b/addons/website/__manifest__.py index ed00569e3a8..7b4b2a7c6e7 100644 --- a/addons/website/__manifest__.py +++ b/addons/website/__manifest__.py @@ -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', diff --git a/addons/website/data/update_theme_images.xml b/addons/website/data/update_theme_images.xml new file mode 100644 index 00000000000..f3f87e4f62d --- /dev/null +++ b/addons/website/data/update_theme_images.xml @@ -0,0 +1,5 @@ + + + + +