summaryrefslogtreecommitdiff
path: root/odoo/addons/base/wizard
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2021-03-24 14:11:46 +0000
committerNicolas Lempereur <nle@odoo.com>2021-04-02 11:57:06 +0000
commit240de08ac8f5dbd2e263a48fea859605770f82a3 (patch)
tree32ce9143d47cccd5a1daf8ca9227671a095a7a8c /odoo/addons/base/wizard
parent0b8d79f65dc96d30fc4737362d3e05e103b281bb (diff)
[FIX] base: generate missing terms ok src dupes
When using "Generate Missing Terms" we export all translations and reimport them with `create_empty_translation` so they empty translation are made available. But since we export all modules in the same PO file, the same terms that might have different translation in different modules would get the same translation value after using "Generate missing terms" which is unexpected => usually we import/export PO file by module and so a term translation is unique for one module only. With this changeset, we import translation module by module. When testing speed of Generate Missing Terms with 90 modules and 37000 translations, the timing taken change like this: - original code: 21 seconds - exporting/importing 1 PO file per module: 45 seconds - exporting 1 TGZ file total/importing 1 PO file per module: 23 seconds opw-2439029 closes odoo/odoo#68663 X-original-commit: f1dd07a7fb1b3c99839072521725cca8cef1eb2e Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'odoo/addons/base/wizard')
-rw-r--r--odoo/addons/base/wizard/base_update_translations.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/odoo/addons/base/wizard/base_update_translations.py b/odoo/addons/base/wizard/base_update_translations.py
index 0ac9b301d7b..40a99f4f133 100644
--- a/odoo/addons/base/wizard/base_update_translations.py
+++ b/odoo/addons/base/wizard/base_update_translations.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import tarfile
import tempfile
from odoo import api, fields, models, tools, _
@@ -27,6 +28,11 @@ class BaseUpdateTranslations(models.TransientModel):
def act_update(self):
with tempfile.NamedTemporaryFile() as buf:
- tools.trans_export(self.lang, ['all'], buf, 'po', self._cr)
- tools.trans_load_data(self._cr, buf, 'po', self.lang, create_empty_translation=True)
+ tools.trans_export(self.lang, ['all'], buf, 'tgz', self._cr)
+ buf.seek(0)
+ tar = tarfile.open(fileobj=buf)
+ for file_info in tar:
+ module_file = tar.extractfile(file_info)
+ tools.trans_load_data(self._cr, module_file, 'po', self.lang, create_empty_translation=True)
+ tar.close()
return {'type': 'ir.actions.act_window_close'}