Skip to content
Permalink
Browse files

[FIX] website_theme_install: theme installation

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.

Co-authored-by: Sébastien Theys <seb@odoo.com>
  • Loading branch information...
rco-odoo and seb-odoo committed Oct 8, 2019
1 parent 3b4a0e8 commit f77e4e424254c9ee5a28fb02fa7dc3272e71ca79
Showing with 8 additions and 15 deletions.
  1. +8 −15 addons/website_theme_install/models/ir_module_module.py
@@ -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):
@@ -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):

0 comments on commit f77e4e4

Please sign in to comment.
You can’t perform that action at this time.