[Menu] Menu association --> bikecoop_l10n_fr
[burette/bikecoop.git] / bikecoop.py
1 # -*- coding: utf-8 -*-
2 from osv import fields, osv
3
4
5 class Theme(osv.osv):
6 _name = 'bikecoop.partner.theme'
7 _description = 'Themes that could be related to a partner'
8
9 _columns = {
10 'code': fields.char('Code', size=8, help='Code of the occupation'),
11 'name': fields.char('Name', size=128, help='Name of the job or studies', required=True, translate=True),
12 'domain': fields.selection([('gender', 'Gender'), ('occupation', 'Occupation'), ('volunteer', 'Volunteer')], 'Domain', required=True, size=24),
13 'active': fields.boolean('Active', help='If check, this object is always available'),
14 }
15
16 _defaults = {
17 'active': lambda *a: 1,
18 }
19
20 Theme()
21
22
23 class Partner(osv.osv):
24 _inherit = 'res.partner'
25
26 _columns = {
27 'nationality_id': fields.many2one('res.country', 'Nationality', help='Partner\'s nationality if he is a person'),
28 'year': fields.integer('Year of birth', help='This partner year of birth'),
29 'occupation_id': fields.many2one('bikecoop.partner.theme', 'Occupation', help='Main occupation of this partner'),
30 'volunteer_ids': fields.many2many('bikecoop.partner.theme', 'res_partner_bikecoop_theme_rel', 'partner_id', 'theme_id', 'Want to be volunteer?', help='What kind of volunteer activities you want to do with us?'),
31 'gender_id': fields.many2one('bikecoop.partner.theme', 'Gender'),
32 }
33
34 def _check_year(self, cr, uid, ids, context=None):
35 obj = self.browse(cr, uid, ids[0], context=context)
36 if obj.year:
37 if obj.year < 1900 or obj.year > 2100:
38 return False
39 return True
40
41 _constraints = [
42 (_check_year, 'Error: this year is not valid.', ['year']),
43 ]
44
45
46 Partner()
47
48 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: