summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2019-10-08 13:32:00 +0000
committerfw-bot <otis@odoo.com>2019-10-10 06:33:16 +0000
commit82186425411d972568dda490b3e47c582ae8ae75 (patch)
treed4aad9d684417ffeeefc0fa042db59acafa8e713 /addons
parent5d7e0b3735daa16cadf17d8ad14444471643bd56 (diff)
[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. closes odoo/odoo#38331 X-original-commit: 03b796b9e92e6eeeee877beaea133bdb6de0c6a3 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/website_theme_install/models/ir_module_module.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/addons/website_theme_install/models/ir_module_module.py b/addons/website_theme_install/models/ir_module_module.py
index b9239df97e9..d8609620dac 100644
--- a/addons/website_theme_install/models/ir_module_module.py
+++ b/addons/website_theme_install/models/ir_module_module.py
@@ -305,19 +305,14 @@ class IrModuleModule(models.Model):
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 @@ class IrModuleModule(models.Model):
# 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):