[DATA] -automatically add group stock user for point of sale managers
[burette/velosenville.git] / res_partner.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 # velosenville module for OpenERP, Vélos en Ville specificities
5 # Copyright (C) 2012-2016 Vélos en Ville (<http://www.velosenville.org>)
6 #
7 # This file is a part of velosenville
8 #
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.
13 #
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.
18 #
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/>.
21 #
22 ##############################################################################
23 from openerp.osv import osv
24 from openerp.osv import fields
25 from datetime import date
26
27
28 class res_partner(osv.osv):
29 _inherit = 'res.partner'
30
31 _columns = {
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'),
34 }
35
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()):
40 return False
41 return True
42
43 _constraints = [
44 (_check_birthdate_date, 'Error: this birthdate is not valid.', ['birthdate']),
45 ]
46 res_partner()
47
48
49 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: