Use Constraint instance in ModelSQL._sql_constraints

issue4814
review15491002
This commit is contained in:
Cédric Krier
2015-06-22 16:58:59 +02:00
parent 773e55b040
commit 7d844159ae
+3 -2
View File
@@ -7,7 +7,7 @@ from itertools import groupby
from sql import Null
from sql.aggregate import Max, Sum
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.model import Workflow, ModelView, ModelSQL, fields, Check
from trytond.pyson import Eval, If, Bool
from trytond.transaction import Transaction
from trytond import backend
@@ -558,8 +558,9 @@ class Line(ModelSQL, ModelView):
'amount_greater_invoice_amount_to_pay': ('Amount "%s" is '
'greater than the amount to pay of invoice.'),
})
t = cls.__table__()
cls._sql_constraints += [
('check_statement_line_amount', 'CHECK(amount != 0)',
('check_statement_line_amount', Check(t, t.amount != 0),
'Amount should be a positive or negative value.'),
]