X-Git-Url: http://git.cyclocoop.org/?p=burette%2Fvelosenville.git;a=blobdiff_plain;f=res_partner.py;fp=res_partner.py;h=db7aa43a616fe7d91246a770ed94ab4d38080c71;hp=0000000000000000000000000000000000000000;hb=5f6e1164222ddfe13f38eb51474a0e5b0118bd8a;hpb=c418c1cb6eae1384b11fc3f32a0f3a1f634c81b1 diff --git a/res_partner.py b/res_partner.py new file mode 100644 index 0000000..db7aa43 --- /dev/null +++ b/res_partner.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# velosenville module for OpenERP, Vélos en Ville specificities +# Copyright (C) 2012-2013 Vélos en Ville () +# +# This file is a part of velosenville +# +# velosenville is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# velosenville is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import osv +from openerp.osv import fields +from datetime import date + + +class res_partner(osv.osv): + _inherit = 'res.partner' + + _columns = { + #Overload birthdate field to have date format. Don't know why it's char type in mainstream version + 'birthdate': fields.date('Birthdate'), + } + + def _check_birthdate(self, cr, uid, ids, context=None): + obj = self.browse(cr, uid, ids[0], context=context) + if obj.birthdate: + if obj.birthdate < '1900-01-01' or obj.birthdate > str(date.today()): + return False + return True + + _constraints = [ + (_check_birthdate, 'Error: this birthdate is not valid.', ['birthdate']), + ] +res_partner() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: