07f8614b83d8ce22e87a738928bd4a428f842838
[burette/bikecoop.git] / bikecoop.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 # Bikecoop module for OpenERP, Custom module for bike coop' Copyright (C)
5 # 2012-2015 L'Heureux Cyclage (<http://www.heureux-cyclage.org>)
6 #
7 # This file is a part of Bikecoop
8 #
9 # Bikecoop is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU General Public License as published by the Free
11 # Software Foundation, either version 3 of the License, or (at your option)
12 # any later version.
13 #
14 # Bikecoop 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
24 from openerp.osv import fields, osv
25 import openerp.addons.decimal_precision as dp
26 from datetime import date
27
28
29 class Theme(osv.osv):
30 _name = 'bikecoop.partner.theme'
31 _description = 'Themes that could be related to a partner'
32 _order = 'domain,sequence,name'
33
34 _columns = {
35 'code': fields.char('Code', size=8, help='Code of the occupation'),
36 'name': fields.char('Name', size=128, help='Name of the job or studies', required=True, translate=True),
37 'domain': fields.selection([('gender', 'Gender'), ('occupation', 'Occupation'), ('volunteer', 'Volunteer')], 'Domain', required=True, size=24),
38 'active': fields.boolean('Active', help='If check, this object is always available'),
39 'sequence': fields.integer('Sequence', help='To order by sequence'),
40 }
41
42 _defaults = {
43 'active': lambda *a: 1,
44 }
45
46 _order = 'name'
47
48 Theme()
49
50
51 class Partner(osv.osv):
52 _inherit = 'res.partner'
53
54 _columns = {
55 'nationality_id': fields.many2one('res.country', 'Nationality', help='Partner\'s nationality if he is a person'),
56 'year': fields.integer('Year of birth', help='This partner year of birth'),
57 'occupation_id': fields.many2one('bikecoop.partner.theme', 'Occupation', help='Main occupation of this partner'),
58 '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?'),
59 'gender_id': fields.many2one('bikecoop.partner.theme', 'Gender'),
60 }
61
62 def _check_year(self, cr, uid, ids, context=None):
63 obj = self.browse(cr, uid, ids[0], context=context)
64 if obj.year:
65 if obj.year < 1900 or obj.year > date.today().year:
66 return False
67 return True
68
69 _constraints = [
70 (_check_year, 'Error: this year is not valid.', ['year']),
71 ]
72 Partner()
73
74
75 class product_template(osv.osv):
76 _inherit = 'product.template'
77
78 _columns = {
79 'standard_price': fields.float('Cost', digits_compute=dp.get_precision('Product Price'), help="Cost price of the product used for standard stock valuation in accounting and used as a base price on purchase orders.", groups="base.group_user,point_of_sale.group_pos_user"),
80 }
81
82 product_template()
83
84
85 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: