Skip to content

Commit

Permalink
[FIX] website_theme_install: theme installation
Browse files Browse the repository at this point in the history
Group the upgrade of upstream dependencies with the installation of a
new theme into a single install/upgrade operation.  This fixes cache
misses occurring when accessing the state of a module after having
upgraded other modules.

closes #38209

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
  • Loading branch information
rco-odoo and seb-odoo committed Oct 9, 2019
1 parent be464a3 commit 03b796b
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions addons/website_theme_install/models/ir_module_module.py
Expand Up @@ -305,19 +305,14 @@ def _theme_get_stream_website_ids(self):
return websites

def _theme_upgrade_upstream(self):
"""
Upgrade the upstream dependencies of a theme.
We only need to upgrade the upper dependency and the rest will chain.
""" Upgrade the upstream dependencies of a theme, and install it if necessary. """
def install_or_upgrade(theme):
if theme.state != 'installed':
theme.button_install()
themes = theme + theme._theme_get_upstream()
themes.filtered(lambda m: m.state == 'installed').button_upgrade()

This upper dependency will usually be theme_common but it can also be different
for example for theme_default and theme_bootswatch which are standalone themes.
:return: recordset of websites ``website``
"""
for theme in self:
upper_theme = (theme + theme._theme_get_upstream())[-1]
if upper_theme.state == 'installed':
upper_theme.button_immediate_upgrade()
self._button_immediate_function(install_or_upgrade)

@api.model
def _theme_remove(self, website):
Expand Down Expand Up @@ -355,11 +350,9 @@ def button_choose_theme(self):
# website.theme_id must be set before upgrade/install to trigger the load in ``write``
website.theme_id = self

# this will install 'self' if it is not installed yet
self._theme_upgrade_upstream()

if self.state != 'installed':
self.button_immediate_install()

return website.button_go_website()

def button_remove_theme(self):
Expand Down

0 comments on commit 03b796b

Please sign in to comment.