changeset f9f50619c89c in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=f9f50619c89c
description:
        Prevent to create more than one resource type translation per module

        issue11343
        review415551004
diffstat:

 trytond/ir/translation.py |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (23 lines):

diff -r e19329d25a6f -r f9f50619c89c trytond/ir/translation.py
--- a/trytond/ir/translation.py Mon Sep 19 21:25:55 2022 +0200
+++ b/trytond/ir/translation.py Sun Sep 25 20:19:30 2022 +0200
@@ -166,14 +166,19 @@
             ir_translation.module, ir_translation.fuzzy, ir_translation.res_id]
 
         def insert(field, type, name, string):
+            inserted = False
             for val in string:
                 if not val or val in translations[type][name]:
                     continue
                 if isinstance(val, LazyString):
                     continue
+                assert type not in {'field', 'help'} or not inserted, (
+                    "More than one resource "
+                    f"for {type} of {name} in {module_name}")
                 cursor.execute(
                     *ir_translation.insert(columns,
                         [[name, 'en', type, val, '', module_name, False, -1]]))
+                inserted = True
 
         for field_name, field in model._fields.items():
             name = model.__name__ + ',' + field_name

Reply via email to