changeset c433e259ed6a in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=c433e259ed6a
description:
Make language code unique
issue10334
review334301004
diffstat:
CHANGELOG | 1 +
trytond/ir/lang.py | 5 ++++-
trytond/ir/message.xml | 3 +++
3 files changed, 8 insertions(+), 1 deletions(-)
diffs (42 lines):
diff -r 0b7759ed0706 -r c433e259ed6a CHANGELOG
--- a/CHANGELOG Tue May 18 22:08:59 2021 +0200
+++ b/CHANGELOG Tue May 18 22:34:43 2021 +0200
@@ -1,3 +1,4 @@
+* Make language code unique
* Support base64 encoded data in ModelStorage.import_data
* Add BOOL_AND and BOOL_OR to SQLite backend
diff -r 0b7759ed0706 -r c433e259ed6a trytond/ir/lang.py
--- a/trytond/ir/lang.py Tue May 18 22:08:59 2021 +0200
+++ b/trytond/ir/lang.py Tue May 18 22:34:43 2021 +0200
@@ -10,7 +10,8 @@
from trytond.cache import Cache
from trytond.exceptions import UserError
from trytond.i18n import gettext
-from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields, Check
+from trytond.model import (
+ ModelView, ModelSQL, DeactivableMixin, fields, Check, Unique)
from trytond.modules import create_graph, load_translations
from trytond.pool import Pool
from trytond.pyson import Eval
@@ -85,6 +86,8 @@
table = cls.__table__()
cls._sql_constraints += [
+ ('code_unique', Unique(table, table.code),
+ 'ir.msg_language_code_unique'),
('check_decimal_point_thousands_sep',
Check(table, table.decimal_point != table.thousands_sep),
'decimal_point and thousands_sep must be different!'),
diff -r 0b7759ed0706 -r c433e259ed6a trytond/ir/message.xml
--- a/trytond/ir/message.xml Tue May 18 22:08:59 2021 +0200
+++ b/trytond/ir/message.xml Tue May 18 22:34:43 2021 +0200
@@ -369,5 +369,8 @@
<record model="ir.message" id="msg_avatar_url">
<field name="text">Avatar URL</field>
</record>
+ <record model="ir.message" id="msg_language_code_unique">
+ <field name="text">The code on language must be unique.</field>
+ </record>
</data>
</tryton>