[FIX]fix constraint to an SQL constraint

bzr revid: csn@openerp.com-20121120100252-ieznyh43zanv2w7q
This commit is contained in:
Cedric Snauwaert 2012-11-20 11:02:52 +01:00
parent 7e193e691c
commit 0e3d3328cc
1 changed files with 2 additions and 8 deletions

View File

@ -470,14 +470,8 @@ class Product(osv.osv):
'membership_date_from': fields.date('Date from', help='Date from which membership becomes active.'),
'membership_date_to': fields.date('Date to', help='Date until which membership remains active.'),
}
def _check_end_date(self, cr, uid, ids, context=None):
for membership in self.browse(cr, uid, ids, context=context):
if membership.membership_date_to < membership.membership_date_from:
return False
return True
_constraints = [
(_check_end_date, 'Error ! Ending Date cannot be set before Beginning Date.', ['membership_date_to']),
]
_sql_constraints = [('date_greater','check(membership_date_to >= membership_date_from)','Error ! Ending Date cannot be set before Beginning Date.')]
_defaults = {
'membership': False,
}