[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>
Tue, 12 Mar 2013 20:17:10 +0000 (21:17 +0100)
bikecoop.py

index e7c8012..732528e 100644 (file)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 from 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()