From: Ludovic CHEVALIER Date: Tue, 12 Mar 2013 19:35:48 +0000 (+0100) Subject: [Partner] +real date type for birthdate field and add to bikecoop membership form... X-Git-Url: https://git.cyclocoop.org/?p=burette%2Fvelosenville.git;a=commitdiff_plain;h=5f6e1164222ddfe13f38eb51474a0e5b0118bd8a [Partner] +real date type for birthdate field and add to bikecoop membership form instead of year --- diff --git a/__init__.py b/__init__.py index e078f98..e563ffa 100644 --- a/__init__.py +++ b/__init__.py @@ -20,5 +20,6 @@ # along with this program. If not, see . # ############################################################################## +import res_partner # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/__openerp__.py b/__openerp__.py index 7207cc5..d2740fb 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -41,6 +41,7 @@ It installs the profile for bike co-ops to manage some features like: 'data/bikecoop.xml', 'data/product.xml', 'data/res_partner.xml', + 'view/bikecoop.xml', ], 'installable': True, 'auto_install': False, 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: diff --git a/view/bikecoop.xml b/view/bikecoop.xml new file mode 100644 index 0000000..f827c9a --- /dev/null +++ b/view/bikecoop.xml @@ -0,0 +1,14 @@ + + + + res.partner.form + res.partner + + + + + + + + +