summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-12-07 11:27:02 +0000
committerRaphael Collet <rco@odoo.com>2020-12-08 09:55:55 +0000
commit4e29fbada592e887459dabee71708c6d0dd01715 (patch)
tree031413cd95c49a76a8ea8542db0f3405681a459f
parent85bf2a3c322436808dbc46f6e0f8a68bf40f1b6c (diff)
[FIX] test_lint: check for duplicate entries in POT files
X-original-commit: 745564629748dbce10156fc164d3f126e8630999
-rw-r--r--addons/l10n_ch/i18n/l10n_ch.pot1
-rw-r--r--odoo/addons/test_lint/tests/__init__.py1
-rw-r--r--odoo/addons/test_lint/tests/test_pofile.py29
3 files changed, 31 insertions, 0 deletions
diff --git a/addons/l10n_ch/i18n/l10n_ch.pot b/addons/l10n_ch/i18n/l10n_ch.pot
index a020dcca858..030abb9a50b 100644
--- a/addons/l10n_ch/i18n/l10n_ch.pot
+++ b/addons/l10n_ch/i18n/l10n_ch.pot
@@ -559,6 +559,7 @@ msgstr ""
msgid "type: [(name, amount, base, formated amount, formated base)]"
msgstr ""
+#. module: l10n_ch
#: code:addons/l10n_ch/models/account_invoice.py:179
#, python-format
msgid "Cannot generate the QR-bill. Please check you have configured the address of your company and debtor. If you are using a QR-IBAN, also check the invoice's payment reference is a QR reference."
diff --git a/odoo/addons/test_lint/tests/__init__.py b/odoo/addons/test_lint/tests/__init__.py
index 681e1270bb5..c28bef7f107 100644
--- a/odoo/addons/test_lint/tests/__init__.py
+++ b/odoo/addons/test_lint/tests/__init__.py
@@ -1,4 +1,5 @@
from . import test_pylint
+from . import test_pofile
from . import test_ecmascript
from . import test_markers
from . import test_onchange_domains
diff --git a/odoo/addons/test_lint/tests/test_pofile.py b/odoo/addons/test_lint/tests/test_pofile.py
new file mode 100644
index 00000000000..61f34a4cc94
--- /dev/null
+++ b/odoo/addons/test_lint/tests/test_pofile.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from collections import Counter
+
+from odoo.modules import get_modules, get_resource_path
+from odoo.tests.common import TransactionCase
+from odoo.tools.translate import TranslationFileReader
+
+
+class PotLinter(TransactionCase):
+ def test_pot_duplicate_entries(self):
+ def format(entry):
+ # TranslationFileReader only returns those three types
+ if entry['type'] == 'model':
+ return ('model', entry['name'], entry['imd_name'])
+ elif entry['type'] == 'model_terms':
+ return ('model_terms', entry['name'], entry['imd_name'], entry['src'])
+ elif entry['type'] == 'code':
+ return ('code', entry['src'])
+
+ # retrieve all modules, and their corresponding POT file
+ for module in get_modules():
+ filename = get_resource_path(module, 'i18n', module + '.pot')
+ if not filename:
+ continue
+ counts = Counter(map(format, TranslationFileReader(filename)))
+ duplicates = [key for key, count in counts.items() if count > 1]
+ self.assertFalse(duplicates, "Duplicate entries found in %s" % filename)