summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core/session.js
diff options
context:
space:
mode:
authorjvm-odoo <jvm@odoo.com>2020-06-10 08:46:10 +0000
committerjvm-odoo <jvm@odoo.com>2020-06-11 14:53:25 +0000
commit149763f372e58c26c4af29a995314d102dfa03ba (patch)
tree9f11f295aa8fa71882ac65fda6b6f7624dbd62ea /addons/web/static/src/js/core/session.js
parentad258ee7d1dd84765543f3e3416a5e86ef869693 (diff)
[FIX] web: load_translation fallback to url language
Issue - Install eCommerce, Sales, Stock, Product availability - Install another language & add it to website too - Create a product - eCommerce tab select 'Availability Show ': inventory below a threshold and prevent sales if not enough stock - Go to website, publish it - Private tab > go on your website url - Open the product page Availability text should show up - Switch language without debugger open Availability text not translated - Open debugger with disable cache - Refresh Availability text translated Cause In this case, we have no user_context, but the load_translation is based on the user_context language. Since lang = undefined, we use the cached language Solution Fallback to the context language if the user_context langague is not defined OPW-2244843 closes odoo/odoo#52868 X-original-commit: a9a756cf75963e0771a05859b29b03f08ae592b1 Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/core/session.js')
-rw-r--r--addons/web/static/src/js/core/session.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js
index a8159469145..354cca6d6f8 100644
--- a/addons/web/static/src/js/core/session.js
+++ b/addons/web/static/src/js/core/session.js
@@ -211,7 +211,17 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
});
},
load_translations: function () {
- return _t.database.load_translations(this, this.module_list, this.user_context.lang, this.translationURL);
+ var lang = this.user_context.lang;
+
+ if (!lang) {
+ this.trigger_up('context_get', {
+ callback: function (ctx) {
+ lang = ctx.lang;
+ },
+ });
+ }
+
+ return _t.database.load_translations(this, this.module_list, lang, this.translationURL);
},
load_css: function (files) {
var self = this;