From 4ba7fbbf81e9f67998a9a4c0659a48e1531b7df3 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 10 Sep 2018 14:26:51 +0200 Subject: [PATCH] [FIX] tools: use pot as reference file In the first attempt at #26134, the pot_targets was cleared after creating the pot_rows object. Since the rows not present in the pot_targets are now skipped, clearing the pot should not be done. Still use a temporary list pot_rows to avoid modifying the list we are iterating on. Update the .po test file to match the new file format Closes #26881 --- odoo/addons/test_translation_import/i18n/fr.po | 2 +- .../i18n/test_translation_import.pot | 2 +- odoo/tools/translate.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/odoo/addons/test_translation_import/i18n/fr.po b/odoo/addons/test_translation_import/i18n/fr.po index 478682cd0a8..3e3abcfe2ab 100644 --- a/odoo/addons/test_translation_import/i18n/fr.po +++ b/odoo/addons/test_translation_import/i18n/fr.po @@ -35,7 +35,7 @@ msgid "test.translation.import" msgstr "test.translation.import in french" #. module: test_translation_import -#: help:test.translation.import,name:0 +#: model:ir.model.fields,help:test_translation_import.field_test_translation_import__name msgid "Efgh" msgstr "Efgh in french" diff --git a/odoo/addons/test_translation_import/i18n/test_translation_import.pot b/odoo/addons/test_translation_import/i18n/test_translation_import.pot index 7d197cd620c..39333d2b363 100644 --- a/odoo/addons/test_translation_import/i18n/test_translation_import.pot +++ b/odoo/addons/test_translation_import/i18n/test_translation_import.pot @@ -41,7 +41,7 @@ msgid "test.translation.import" msgstr "" #. module: test_translation_import -#: help:test.translation.import,name:0 +#: model:ir.model.fields,help:test_translation_import.field_test_translation_import__name msgid "Efgh" msgstr "" diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index 575742c8e3f..4533c8a9bc7 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -1101,14 +1101,15 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True, # discard the target from the POT targets. src = dic['src'] + target_key = (dic['type'], dic['name'], dic['type'] != 'code' and dic['res_id'] or 0) target = pot_targets.get(src) - if not target or (dic['type'], dic['name'], dic['res_id']) not in target.targets: + if not target or target_key not in target.targets: _logger.info("Translation '%s' (%s, %s, %s) not found in reference pot, skipping", src[:60], dic['type'], dic['name'], dic['res_id']) return target.value = dic['value'] - target.targets.discard((dic['type'], dic['name'], dic['type'] != 'code' and dic['res_id'] or 0)) + target.targets.discard(target_key) # This would skip terms that fail to specify a res_id res_id = dic['res_id'] @@ -1143,7 +1144,6 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True, if target.value: for type, name, res_id in target.targets: pot_rows.append((type, name, res_id, src, target.value, target.comments)) - pot_targets.clear() for row in pot_rows: process_row(row)