From dc09fc5b18e35292e1b60380028b7e7faaa2bdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 22 Jun 2015 16:59:41 +0200 Subject: [PATCH] Use Constraint instance in ModelSQL._sql_constraints issue4814 review15491002 --- work.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/work.py b/work.py index 1044a236a8..e1b1c41884 100644 --- a/work.py +++ b/work.py @@ -4,7 +4,7 @@ import datetime from sql import Null -from trytond.model import ModelView, ModelSQL, fields +from trytond.model import ModelView, ModelSQL, fields, Unique from trytond.pyson import Eval from trytond import backend from trytond.transaction import Transaction @@ -122,8 +122,10 @@ class Work(ModelSQL, ModelView): @classmethod def __setup__(cls): super(Work, cls).__setup__() + t = cls.__table__() cls._sql_constraints += [ - ('work_uniq', 'UNIQUE(work)', 'There should be only one ' + ('work_uniq', Unique(t, t.work), + 'There should be only one ' 'timesheet work by task/project.'), ] cls._order.insert(0, ('sequence', 'ASC'))