[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
This commit is contained in:
Martin Trigaux
2018-08-28 18:09:36 +02:00
parent 9e6e0da06f
commit fe9cd11ab5
@@ -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'}