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