[Partner] ~year of birth constraints. Must be greater than current year.
authorLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Tue, 12 Mar 2013 20:17:10 +0000 (21:17 +0100)
committerLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Thu, 28 Mar 2013 08:44:04 +0000 (09:44 +0100)
bikecoop.py

index 8168ace..b851607 100644 (file)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 from openerp.osv import fields, osv
 import openerp.addons.decimal_precision as dp
+from datetime import date
 
 
 class Theme(osv.osv):
@@ -35,15 +36,13 @@ class Partner(osv.osv):
     def _check_year(self, cr, uid, ids, context=None):
         obj = self.browse(cr, uid, ids[0], context=context)
         if obj.year:
-            if obj.year < 1900 or obj.year > 2100:
+            if obj.year < 1900 or obj.year > date.today().year:
                 return False
         return True
 
     _constraints = [
         (_check_year, 'Error: this year is not valid.', ['year']),
     ]
-
-
 Partner()