From 15bf41270d3abb607e7b623b59355594cad170cf Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 26 Jul 2017 13:52:26 +0200 Subject: [PATCH] [FIX] website: Make Qweb cache website dependent Without this patch, all Qweb cache is shared among all available websites. This turns impossible in practice to actually create multiple websites with different look. This closes odoo/odoo#18462 --- odoo/addons/base/ir/ir_qweb/ir_qweb.py | 6 +++--- odoo/addons/base/ir/ir_ui_view.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odoo/addons/base/ir/ir_qweb/ir_qweb.py b/odoo/addons/base/ir/ir_qweb/ir_qweb.py index ddb1c64d73d..a3e63df6bea 100644 --- a/odoo/addons/base/ir/ir_qweb/ir_qweb.py +++ b/odoo/addons/base/ir/ir_qweb/ir_qweb.py @@ -62,7 +62,7 @@ class IrQWeb(models.AbstractModel, QWeb): # assume cache will be invalidated by third party on write to ir.ui.view def _get_template_cache_keys(self): """ Return the list of context keys to use for caching ``_get_template``. """ - return ['lang', 'inherit_branding', 'editable', 'translatable', 'edit_translations'] + return ['lang', 'inherit_branding', 'editable', 'translatable', 'edit_translations', 'website_id'] # apply ormcache_context decorator unless in dev mode... @tools.conditional( @@ -186,14 +186,14 @@ class IrQWeb(models.AbstractModel, QWeb): # in non-xml-debug mode we want assets to be cached forever, and the admin can force a cache clear # by restarting the server after updating the source code (or using the "Clear server cache" in debug tools) 'xml' not in tools.config['dev_mode'], - tools.ormcache('xmlid', 'options.get("lang", "en_US")', 'css', 'js', 'debug', 'async'), + tools.ormcache_context('xmlid', 'options.get("lang", "en_US")', 'css', 'js', 'debug', 'async', keys=("website_id",)), ) def _get_asset(self, xmlid, options, css=True, js=True, debug=False, async=False, values=None): files, remains = self._get_asset_content(xmlid, options) asset = AssetsBundle(xmlid, files, remains, env=self.env) return asset.to_html(css=css, js=js, debug=debug, async=async, url_for=(values or {}).get('url_for', lambda url: url)) - @tools.ormcache('xmlid', 'options.get("lang", "en_US")') + @tools.ormcache_context('xmlid', 'options.get("lang", "en_US")', keys=("website_id",)) def _get_asset_content(self, xmlid, options): options = dict(options, inherit_branding=False, inherit_branding_auto=False, diff --git a/odoo/addons/base/ir/ir_ui_view.py b/odoo/addons/base/ir/ir_ui_view.py index 66cf87c7ee9..edbaf5b392d 100644 --- a/odoo/addons/base/ir/ir_ui_view.py +++ b/odoo/addons/base/ir/ir_ui_view.py @@ -912,7 +912,7 @@ actual arch. def _read_template_keys(self): """ Return the list of context keys to use for caching ``_read_template``. """ - return ['lang', 'inherit_branding', 'editable', 'translatable', 'edit_translations'] + return ['lang', 'inherit_branding', 'editable', 'translatable', 'edit_translations', 'website_id'] # apply ormcache_context decorator unless in dev mode... @api.model