From f481ca689a1c4e796246eb2523c4e3bf864e3944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 22 Jun 2015 16:59:35 +0200 Subject: [PATCH] Use Constraint instance in ModelSQL._sql_constraints issue4814 review15491002 --- move.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/move.py b/move.py index 28d9d1a949..9d5e37ce30 100644 --- a/move.py +++ b/move.py @@ -1,7 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from decimal import Decimal -from trytond.model import Workflow, ModelView, fields +from trytond.model import Workflow, ModelView, fields, Check from trytond.pool import Pool, PoolMeta __all__ = ['Move'] @@ -15,11 +15,12 @@ class Move: @classmethod def __setup__(cls): super(Move, cls).__setup__() + t = cls.__table__() cls._sql_constraints += [ - ('check_fifo_quantity_out', - 'CHECK(quantity >= fifo_quantity)', - 'FIFO quantity can not be greater than quantity.'), - ] + ('check_fifo_quantity_out', + Check(t, t.quantity >= t.fifo_quantity), + 'FIFO quantity can not be greater than quantity.'), + ] cls._error_messages.update({ 'del_move_fifo': ('You can not delete move "%s" that is used ' 'for FIFO cost price.'),