From bf14a04010bcc486e1abe425b27ec4cf0b191b04 Mon Sep 17 00:00:00 2001 From: jvm-odoo Date: Wed, 12 Feb 2020 07:18:28 +0000 Subject: [PATCH] [FIX] web: fix translation dialog should use only active languages Issue - Install CRM and at least 3 languages - Deactivate one of them - Go to CRM > Configuration > Activity Type - Edit an activity type and try to edit translation Traceback (Cannot read property '1' of undefined) Cause This is because all the translations are fetched but we don't look if the language they use is active. So at one moment, the relatedLanguage is undefined and we do relatedLanguage[1] Solution Filter the translation, to keep only the ones with an active language. OPW-2193969 closes odoo/odoo#45215 X-original-commit: 9d1259da1bfd60362ec93996f723a4e378434dc8 Signed-off-by: Jason Van Malder (jvm) --- addons/web/static/src/js/widgets/translation_dialog.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/widgets/translation_dialog.js b/addons/web/static/src/js/widgets/translation_dialog.js index 426ef68cb35..434b7ebcffe 100644 --- a/addons/web/static/src/js/widgets/translation_dialog.js +++ b/addons/web/static/src/js/widgets/translation_dialog.js @@ -57,10 +57,10 @@ odoo.define('web.TranslationDialog', function (require) { this._super(), this._loadLanguages().then((l) => { this.languages = l; + return this._loadTranslations().then((t) => { + this.translations = t; + }); }), - this._loadTranslations().then((t) => { - this.translations = t; - }) ]).then(() => { this.data = this.translations.map((term) => { let relatedLanguage = this.languages.find((language) => language[0] === term.lang); @@ -91,11 +91,12 @@ odoo.define('web.TranslationDialog', function (require) { * @private */ _loadTranslations: function () { + const domain = [...this.domain, ['lang', 'in', this.languages.map(l => l[0])]]; return this._rpc({ model: 'ir.translation', method: 'search_read', fields: ['lang', 'src', 'value'], - domain: this.domain, + domain: domain, }); }, /**