Skip to content
Permalink
Browse files

make `_theme_upgrade_upstream` implicitly install the theme

  • Loading branch information...
rco-odoo committed Oct 9, 2019
1 parent 3e0ba47 commit f779fa87228666788fc97c596d34cecd0fb883b8
Showing with 9 additions and 11 deletions.
  1. +9 −11 addons/website_theme_install/models/ir_module_module.py
@@ -305,13 +305,14 @@ def _theme_get_stream_website_ids(self):
return websites

def _theme_upgrade_upstream(self):
""" Upgrade the upstream dependencies of a theme. """
self._button_immediate_function(type(self)._theme_prepare_upgrade_upstream)
""" 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()

def _theme_prepare_upgrade_upstream(self):
themes = self + self._theme_get_upstream()
themes_to_upgrade = themes.filtered(lambda m: m.state == 'installed')
themes_to_upgrade.button_upgrade()
self._button_immediate_function(install_or_upgrade)

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

def install_or_upgrade(theme):
theme._theme_prepare_upgrade_upstream()
theme.button_install()

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

return website.button_go_website()

0 comments on commit f779fa8

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