Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] website: update theme images also during updates #163449

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Apr 25, 2024

In order for preview images to be shown in the theme selection page, the update_theme_images 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 defiend, at the time update_list() is called from loading.py when using -u on the command line, the modules are not loaded yet, and therefore the override is not applied.
Because of this, when a database was upgraded between 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

Forward-Port-Of: #163118
Forward-Port-Of: #160452

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: 46c889b
The image displayed in the theme selection page is the last one that
was created out of the theme's manifest's `images` entry.
Because of this, when a theme has a different non-last image in a new
version compared to an old version, that image becomes the last created
one and is displayed in the theme selection page instead of the expected
screenshot image.

This commit preserves the order that was specified in the `images`
definition by re-creating all images instead of only the modified ones -
if an update is needed at all.

Steps to reproduce:
- Install `website` with a theme in 14.0.
- Upgrade to 15.0.
- Go to the theme selection page.

=> Some themes (e.g. `theme_beauty`) displayed their cover picture
instead of their screenshot.

task-2719425

X-original-commit: 8a3315a
@robodoo
Copy link
Contributor

robodoo commented Apr 25, 2024

@fw-bot
Copy link
Contributor Author

fw-bot commented Apr 25, 2024

This PR targets saas-17.2 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Apr 25, 2024
@C3POdoo C3POdoo added the RD research & development, internal work label Apr 25, 2024
robodoo pushed a commit that referenced this pull request Apr 26, 2024
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: 46c889b
Part-of: #163449
robodoo pushed a commit that referenced this pull request Apr 26, 2024
The image displayed in the theme selection page is the last one that
was created out of the theme's manifest's `images` entry.
Because of this, when a theme has a different non-last image in a new
version compared to an old version, that image becomes the last created
one and is displayed in the theme selection page instead of the expected
screenshot image.

This commit preserves the order that was specified in the `images`
definition by re-creating all images instead of only the modified ones -
if an update is needed at all.

Steps to reproduce:
- Install `website` with a theme in 14.0.
- Upgrade to 15.0.
- Go to the theme selection page.

=> Some themes (e.g. `theme_beauty`) displayed their cover picture
instead of their screenshot.

task-2719425

closes #163449

X-original-commit: 8a3315a
Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
@robodoo robodoo closed this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants