X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=eturecup.py;h=14a3298b30e2c01829532a4348da31da07cfc47c;hb=4d7b40d51c8e1183d91ba107fcf33f7fd0bd4359;hp=3648b47711687dcfc34de7d059667bacf210a108;hpb=87cabdadfdbb29bfd31bc190733e50ac36f67172;p=burette%2Feturecup.git
diff --git a/eturecup.py b/eturecup.py
index 3648b47..14a3298 100644
--- a/eturecup.py
+++ b/eturecup.py
@@ -2,7 +2,7 @@
##############################################################################
#
# eturecup module for OpenERP, Custom module for Ãtu'Récup
-# Copyright (C) 2014-2015 Ãtu'Récup ()
+# Copyright (C) 2014-2017 Ãtu'Récup ()
#
# This file is a part of eturecup
#
@@ -21,7 +21,6 @@
#
##############################################################################
-from openerp.osv import osv
from openerp.osv import orm
from openerp.osv import fields
@@ -29,12 +28,53 @@ from openerp.osv import fields
class Partner(orm.Model):
_inherit = 'res.partner'
+ def _get_bikecoop_theme_type(self, cr, uid, ids, name, args, context=None):
+ """Return themes type for selected partners"""
+ res = {}
+ partners = self.browse(cr, uid, ids, context=context)
+ for partner in partners:
+ res[partner.id] = False
+ if partner.occupation_id.type == 'studies':
+ res[partner.id] = True
+ return res
+
+ def onchange_occupation_id(self, cr, uid, ids, occupation_id):
+ """Define if a partner is a student based on his/her occupation type"""
+ v = {}
+ partners = self.browse(cr, uid, ids)
+ occupations = self.pool.get('bikecoop.partner.theme')
+ for partner in partners:
+ v['is_student'] = False
+ occupation = occupations.browse(cr, uid, occupation_id)
+ if occupation.type == 'studies':
+ v['is_student'] = True
+ return {'value': v}
+
_columns = {
- 'newsletter': fields.boolean('Do you want to receive our monthly newsletter?'),
+ 'newsletter': fields.boolean(
+ 'Do you want to receive our monthly newsletter?'),
+ 'is_student': fields.function(_get_bikecoop_theme_type,
+ method=True,
+ string='Is this partner a student?',
+ type='boolean',
+ store=True),
+ 'scholarship': fields.boolean('Scholarship',
+ help='Is this student a scholarship?'),
'want_to_be_volunteer': fields.boolean(
- 'Do you want to receive some informations about volunteer activities?',
+ 'Do you want to receive some informations about volunteer \
+ activities?',
help='⦠in company and its activities: bikecoop, events, â¦'),
}
+class Theme(orm.Model):
+ _inherit = 'bikecoop.partner.theme'
+
+ _columns = {
+ 'type': fields.selection([('studies', 'Studies')],
+ 'Type',
+ help='An extra field to categorize themes.'),
+ }
+
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: