changeset 2145:624b2073a43e

health_lab : task #13709, Migration to Tryton 3.8. Update constraints to Python SQL
author Luis Falcon <falcon@gnu.org>
date Tue, 10 Nov 2015 15:56:57 +0000
parents ac730334e5fd
children 91781420d72c
files tryton/health_lab/health_lab.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health_lab/health_lab.py
+++ b/tryton/health_lab/health_lab.py
@@ -21,7 +21,7 @@
 #
 ##############################################################################
 from datetime import datetime
-from trytond.model import ModelView, ModelSingleton, ModelSQL, fields
+from trytond.model import ModelView, ModelSingleton, ModelSQL, fields, Unique
 from trytond.transaction import Transaction
 from trytond.pool import Pool
 
@@ -68,8 +68,10 @@
     @classmethod
     def __setup__(cls):
         super(TestType, cls).__setup__()
+        t = cls.__table__()
         cls._sql_constraints = [
-            ('code_uniq', 'unique(name)', 'The Lab Test code must be unique'),
+            ('code_uniq', Unique(t, t.name),
+             'The Lab Test code must be unique')
         ]
 
     @classmethod
@@ -114,8 +116,10 @@
     @classmethod
     def __setup__(cls):
         super(Lab, cls).__setup__()
-        cls._sql_constraints += [
-            ('id_uniq', 'unique (name)', 'The test ID code must be unique'),
+        t = cls.__table__()
+        cls._sql_constraints = [
+            ('id_uniq', Unique(t, t.name),
+             'The test ID code must be unique')
         ]
 
     @staticmethod
@@ -151,10 +155,13 @@
     @classmethod
     def __setup__(cls):
         super(GnuHealthLabTestUnits, cls).__setup__()
+        t = cls.__table__()
         cls._sql_constraints = [
-            ('name_uniq', 'unique(name)', 'The Unit name must be unique'),
+            ('name_uniq', Unique(t, t.name),
+             'The Unit name must be unique')
         ]
 
+
     @classmethod
     def check_xml_record(cls, records, values):
         return True