1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # velosenville module for OpenERP, Vélos en Ville specificities
5 # Copyright (C) 2012-2013 Vélos en Ville (<http://www.velosenville.org>)
7 # This file is a part of velosenville
9 # velosenville is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # velosenville is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ##############################################################################
23 from openerp
.osv
import osv
24 from openerp
.osv
import fields
25 from datetime
import date
28 class res_partner(osv
.osv
):
29 _inherit
= 'res.partner'
32 #Overload birthdate field to have date format. Don't know why it's char type in mainstream version
33 'birthdate_date': fields
.date('Birthdate'),
36 def _check_birthdate_date(self
, cr
, uid
, ids
, context
=None):
37 obj
= self
.browse(cr
, uid
, ids
[0], context
=context
)
38 if obj
.birthdate_date
:
39 if obj
.birthdate_date
< '1900-01-01' or obj
.birthdate_date
> str(date
.today()):
44 (_check_birthdate_date
, 'Error: this birthdate is not valid.', ['birthdate']),
49 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: