[IMP] removal of usages of the deprecated node.getchildren call, better usage of...
[odoo/odoo.git] / addons / hr_contract / hr_contract.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution   
5 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6 #    $Id$
7 #
8 #    This program is free software: you can redistribute it and/or modify
9 #    it under the terms of the GNU General Public License as published by
10 #    the Free Software Foundation, either version 3 of the License, or
11 #    (at your option) any later version.
12 #
13 #    This program is distributed in the hope that it will be useful,
14 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #    GNU General Public License for more details.
17 #
18 #    You should have received a copy of the GNU General Public License
19 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 #
21 ##############################################################################
22
23
24 from osv import fields, osv
25 import time
26
27 class hr_employee_marital_status(osv.osv):
28     _name = "hr.employee.marital.status"
29     _description = "Employee Marital Status"
30     _columns = {
31         'name' : fields.char('Marital Status', size=30, required=True),
32         'description' : fields.text('Status Description'),
33     }
34 hr_employee_marital_status()
35
36 class hr_employee(osv.osv):
37     _name = "hr.employee"
38     _description = "Employee"
39     _inherit = "hr.employee"
40     _columns = {
41         'manager' : fields.boolean('Manager'),
42         'medic_exam' : fields.date('Medical examination date'),
43         'audiens_num' : fields.char('AUDIENS Number', size=30),
44         'place_of_birth' : fields.char('Place of Birth', size=30),
45         'marital_status' : fields.many2one('hr.employee.marital.status', 'Marital Status'),
46         'children' : fields.integer('Number of children'),
47         'contract_ids' : fields.one2many('hr.contract', 'employee_id', 'Contracts'),
48     }
49 hr_employee()
50
51 #Contract wage type period name
52 class hr_contract_wage_type_period(osv.osv):
53     _name='hr.contract.wage.type.period'
54     _description='Wage Period'
55     _columns = {
56         'name' : fields.char('Period Name', size=50, required=True, select=True),
57         'factor_days': fields.float('Hours in the period', digits=(12,4), required=True, help='This field is used by the timesheet system to compute the price of an hour of work wased on the contract of the employee')
58     }
59     _defaults = {
60         'factor_days': lambda *args: 168.0
61     }
62 hr_contract_wage_type_period()
63
64 #Contract wage type (hourly, daily, monthly, ...)
65 class hr_contract_wage_type(osv.osv):
66     _name = 'hr.contract.wage.type'
67     _description = 'Wage Type'
68     _columns = {
69         'name' : fields.char('Wage Type Name', size=50, required=True, select=True),
70         'period_id' : fields.many2one('hr.contract.wage.type.period', 'Wage Period', required=True),
71         'type' : fields.selection([('gross','Gross'), ('net','Net')], 'Type', required=True),
72         'factor_type': fields.float('Factor for hour cost', digits=(12,4), required=True, help='This field is used by the timesheet system to compute the price of an hour of work wased on the contract of the employee')
73     }
74     _defaults = {
75         'type' : lambda *a : 'gross',
76         'factor_type': lambda *args: 1.8
77     }
78 hr_contract_wage_type()
79
80 class hr_contract(osv.osv):
81     _name = 'hr.contract'
82     _description = 'Contract'
83     _columns = {
84         'name' : fields.char('Contract Name', size=30, required=True),
85         'employee_id' : fields.many2one('hr.employee', 'Employee', required=True),
86         'function' : fields.many2one('res.partner.function', 'Function'),
87         'date_start' : fields.date('Start Date', required=True),
88         'date_end' : fields.date('End Date'),
89         'working_hours_per_day' : fields.integer('Working hours per day'),
90         'wage_type_id' : fields.many2one('hr.contract.wage.type', 'Wage Type', required=True),
91         'wage' : fields.float('Wage', required=True),
92         'notes' : fields.text('Notes'),
93     }
94     _defaults = {
95         'date_start' : lambda *a : time.strftime("%Y-%m-%d"),
96         'working_hours_per_day' : lambda *a : 8,
97     }
98 hr_contract()
99
100
101 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
102