From fe9cd11ab514c93dbcfa5b127f7fb78eb932886f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 27 Aug 2018 16:58:20 +0200 Subject: [PATCH] [FIX] base: generate translations in po format Instead of csv, it allows to benefit from some features of POFile class like handeling the duplicated terms correctly In #26553, generating the missing terms was creating a new translation for base.xml with no translation (value=src), making a previously translated term no longer translated. Closes #26614 Fixes #26553 --- .../base/module/wizard/base_update_translations.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/odoo/addons/base/module/wizard/base_update_translations.py b/odoo/addons/base/module/wizard/base_update_translations.py index f9c9c0c8555..145176e2db5 100644 --- a/odoo/addons/base/module/wizard/base_update_translations.py +++ b/odoo/addons/base/module/wizard/base_update_translations.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import contextlib -import io +import tempfile from odoo import api, fields, models, tools, _ from odoo.exceptions import UserError @@ -30,7 +29,7 @@ class BaseUpdateTranslations(models.TransientModel): def act_update(self): this = self[0] lang_name = self._get_lang_name(this.lang) - with contextlib.closing(io.BytesIO()) as buf: - tools.trans_export(this.lang, ['all'], buf, 'csv', self._cr) - tools.trans_load_data(self._cr, buf, 'csv', this.lang, lang_name=lang_name) + with tempfile.NamedTemporaryFile() as buf: + tools.trans_export(this.lang, ['all'], buf, 'po', self._cr) + tools.trans_load_data(self._cr, buf, 'po', this.lang, lang_name=lang_name) return {'type': 'ir.actions.act_window_close'}