[REF] purchase: search view of purchase order and form view of merge order wizard
[odoo/odoo.git] / addons / hr_contract / hr_contract.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22
23 from osv import fields, osv
24 import time
25
26 class hr_employee(osv.osv):
27     _name = "hr.employee"
28     _description = "Employee"
29     _inherit = "hr.employee"
30     _columns = {
31         'manager' : fields.boolean('Manager'),
32         'medic_exam' : fields.date('Medical Examination Date'),
33         'place_of_birth' : fields.char('Place of Birth', size=30),
34         'children' : fields.integer('Number of Children'),
35         'vehicle' : fields.integer('Company Vehicle'),
36         'vehicle_distance' : fields.integer('Home-Work Distance', help="In kilometers"),
37         'contract_ids' : fields.one2many('hr.contract', 'employee_id', 'Contracts'),
38     }
39 hr_employee()
40
41 #Contract wage type period name
42 class hr_contract_wage_type_period(osv.osv):
43     _name='hr.contract.wage.type.period'
44     _description='Wage Period'
45     _columns = {
46         'name' : fields.char('Period Name', size=50, required=True, select=True),
47         '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')
48     }
49     _defaults = {
50         'factor_days': lambda *args: 168.0
51     }
52 hr_contract_wage_type_period()
53
54 #Contract wage type (hourly, daily, monthly, ...)
55 class hr_contract_wage_type(osv.osv):
56     _name = 'hr.contract.wage.type'
57     _description = 'Wage Type'
58     _columns = {
59         'name' : fields.char('Wage Type Name', size=50, required=True, select=True),
60         'period_id' : fields.many2one('hr.contract.wage.type.period', 'Wage Period', required=True),
61         'type' : fields.selection([('gross','Gross'), ('net','Net')], 'Type', required=True),
62         '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')
63     }
64     _defaults = {
65         'type' : lambda *a : 'gross',
66         'factor_type': lambda *args: 1.8
67     }
68 hr_contract_wage_type()
69
70
71 class hr_contract_type(osv.osv):
72     _name = 'hr.contract.type'
73     _description = 'Contract Type'
74     _columns = {
75         'name' : fields.char('Contract Type', size=30, required=True),
76     }
77 hr_contract_type()
78
79 class hr_contract(osv.osv):
80     _name = 'hr.contract'
81     _description = 'Contract'
82     _columns = {
83         'name': fields.char('Contract Reference', size=30, required=True),
84         'employee_id': fields.many2one('hr.employee', "Employee", required=True),
85         'department_id': fields.related('employee_id','department_id', string="Department", readonly=True),
86         'type_id': fields.many2one('hr.contract.type', "Contract Type"),
87         'job_id': fields.many2one('hr.job', 'Job Title'),
88         'date_start': fields.date('Start Date', required=True),
89         'date_end': fields.date('End Date'),
90         'working_hours': fields.many2one('resource.calendar','Working hours'),
91         'wage_type_id': fields.many2one('hr.contract.wage.type', 'Wage Type', required=True),
92         'wage': fields.float('Wage', digits=(16,2), required=True),
93         'advantages': fields.text('Advantages'),
94         'advantages_net': fields.float('Net Advantages Value', digits=(16,2)),
95         'advantages_gross': fields.float('Gross Advantages Value', digits=(16,2)),
96         'notes': fields.text('Notes'),
97     }
98     _defaults = {
99         'date_start' : lambda *a : time.strftime("%Y-%m-%d"),
100     }
101 hr_contract()
102
103
104 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
105