[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) <jvm@odoo.com>
This commit is contained in:
jvm-odoo
2020-02-12 15:07:05 +00:00
parent 9a4da8894f
commit bf14a04010
@@ -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,
});
},
/**