diff options
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/session.js | 15 | ||||
| -rw-r--r-- | addons/web/static/src/js/core/translation.js | 9 |
2 files changed, 19 insertions, 5 deletions
diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index 21103a9529a..e083bb71e7f 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -241,8 +241,11 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { }); }, load_qweb: function (mods) { + var self = this; var lock = this.qweb_mutex.exec(function () { - return $.get('/web/webclient/qweb?mods=' + mods).then(function (doc) { + var cacheId = self.cache_hashes && self.cache_hashes.qweb; + var route = '/web/webclient/qweb/' + (cacheId ? cacheId : Date.now()) + '?mods=' + mods; + return $.get(route).then(function (doc) { if (!doc) { return; } qweb.add_template(doc); }); @@ -344,10 +347,18 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { getTZOffset: function (date) { return -new Date(date).getTimezoneOffset(); }, - //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- + /** + * Replaces the value of a key in cache_hashes (the hash of some resource computed on the back-end by a unique value + * @param {string} key the key in the cache_hashes to invalidate + */ + invalidateCacheKey: function(key) { + if (this.cache_hashes && this.cache_hashes[key]) { + this.cache_hashes[key] = Date.now(); + } + }, /** * Reload the currencies (initially given in session_info). This is meant to diff --git a/addons/web/static/src/js/core/translation.js b/addons/web/static/src/js/core/translation.js index 83c556c3c37..416ea9130d2 100644 --- a/addons/web/static/src/js/core/translation.js +++ b/addons/web/static/src/js/core/translation.js @@ -62,9 +62,12 @@ var TranslationDataBase = Class.extend(/** @lends instance.TranslationDataBase# */ load_translations: function(session, modules, lang, url) { var self = this; - return session.rpc(url || '/web/webclient/translations', { - "mods": modules || null, - "lang": lang || null + var cacheId = session.cache_hashes && session.cache_hashes.translations; + url = url || '/web/webclient/translations'; + url += '/' + (cacheId ? cacheId : Date.now()); + return $.get(url, { + mods: modules ? modules.join(',') : null, + lang: lang || null, }).then(function (trans) { self.set_bundle(trans); }); |
