From cf1b1b6e2c15c2ef443044ee58cfd04e1488039c Mon Sep 17 00:00:00 2001 From: chirag Date: Tue, 10 Apr 2018 16:02:05 +0530 Subject: [PATCH] [FIX] l10n_multilang: overwrite existing translations When a record is created in a different language than English, empty translations are created using the _set_ids method for translatable fields. l10n_multilang makes the account translatable, an empty translation is created when the CoA data is processed. After the CoA installation, l10n_multilang transfer the translations of the account templates to the related accounts. No need to create translation terms again, use _set_ids to update the existing translations. This will prevent a cause of translation duplication, forbidden in the future by 160d657704037 opw-1832071 Closes #24158 --- addons/l10n_multilang/models/l10n_multilang.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/l10n_multilang/models/l10n_multilang.py b/addons/l10n_multilang/models/l10n_multilang.py index fe2f48a79e2..f43ebab1f29 100644 --- a/addons/l10n_multilang/models/l10n_multilang.py +++ b/addons/l10n_multilang/models/l10n_multilang.py @@ -32,14 +32,14 @@ class AccountChartTemplate(models.Model): for element in in_ids.with_context(lang=None): if value[element.id]: #copy Translation from Source to Destination object - xlat_obj.create({ - 'name': out_ids._name + ',' + in_field, - 'type': 'model', - 'res_id': out_ids[counter].id, - 'lang': lang, - 'src': element[in_field], - 'value': value[element.id], - }) + xlat_obj._set_ids( + out_ids._name + ',' + in_field, + 'model', + lang, + out_ids[counter].ids, + value[element.id], + element[in_field] + ) else: _logger.info('Language: %s. Translation from template: there is no translation available for %s!' % (lang, element[in_field])) counter += 1