[IMP]:survey,hr_evaluation.
[odoo/odoo.git] / addons / hr_evaluation / hr_evaluation.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 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 import time
23 from osv import fields, osv
24
25 class hr_evaluation_plan(osv.osv):
26     _name = "hr_evaluation.plan"
27     _description = "Evaluation Plan"
28     _columns = {
29         'name': fields.char("Evaluation Plan", size=64, required=True),
30         'company_id': fields.many2one('res.company', 'Company', required=True),
31         'phase_ids' : fields.one2many('hr_evaluation.plan.phase', 'plan_id', 'Evaluation Phases'),
32         'month_first': fields.integer('First Evaluation After'),
33         'month_next': fields.integer('Next Evaluation After'),
34         'active': fields.boolean('Active')
35     }
36     _defaults = {
37         'active' : lambda *a: True,
38     }
39 hr_evaluation_plan()
40
41 class hr_evaluation_plan_phase(osv.osv):
42     _name = "hr_evaluation.plan.phase"
43     _description = "Evaluation Plan Phase"
44     _order = "sequence"
45     _columns = {
46         'name': fields.char("Phase", size=64, required=True),
47         'sequence': fields.integer("Sequence"),
48         'company_id': fields.related('plan_id','company_id',type='many2one',relation='res.company',string='Company',store=True),
49         'plan_id': fields.many2one('hr_evaluation.plan','Evaluation Plan', required=True, ondelete='cascade'),
50         'action': fields.selection([
51             ('top-down','Top-Down Appraisal Requests'),
52             ('bottom-up','Bottom-Up Appraisal Requests'),
53             ('self','Self Appraisal Requests'),
54             ('final','Final Interview')], 'Action', required=True),
55         'survey_id': fields.many2one('survey','Appraisal Form',required=True),
56         'send_answer_manager': fields.boolean('All Answers',
57             help="Send all answers to the manager"),
58         'send_answer_employee': fields.boolean('All Answers',
59             help="Send all answers to the employee"),
60         'send_anonymous_manager': fields.boolean('Anonymous Summary',
61             help="Send an anonymous summary to the manager"),
62         'send_anonymous_employee': fields.boolean('Anonymous Summary',
63             help="Send an anonymous summary to the employee"),
64         'wait': fields.boolean('Wait Previous Phases',
65             help="Check this box if you want to wait that all preceeding phases " +
66               "are finished before launching this phase.")
67
68     }
69     _defaults = {
70         'sequence' : lambda *a: 1,
71     }
72 hr_evaluation_plan_phase()
73
74 class hr_employee(osv.osv):
75     _inherit="hr.employee"
76     _columns = {
77         'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Evaluation Plan'),
78         'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation"),
79     }
80     def onchange_evaluation_plan_id(self, *args):
81         # return the right evaluation date
82         pass
83 hr_employee()
84
85 class hr_evaluation(osv.osv):
86     _name = "hr_evaluation.evaluation"
87     _description = "Employee Evaluation"
88     _rec_name = 'employee_id'
89     _columns = {
90         'date': fields.date("Evaluation Deadline", required=True),
91         'employee_id': fields.many2one('hr.employee', "Employee", required=True),
92         'manager_id': fields.many2one('res.users', "Manager", required=True),
93         'note_summary': fields.text('Evaluation Summary'),
94         'note_action': fields.text('Action Plan',
95             help="If the evaluation does not meet the expectations, you can propose"+
96               "an action plan"),
97         'rating': fields.selection([
98             ('0','Significantly bellow expectations'),
99             ('1','Did not meet expectations'),
100             ('2','Meet expectations'),
101             ('3','Exceeds expectations'),
102             ('4','Significantly exceeds expectations'),
103         ], "Overall Rating", help="This is the overall rating on that summarize the evaluation"),
104         'survey_request_ids': fields.many2many('survey.request',
105             'hr_evaluation_evaluation_requests',
106             'evaluation_id',
107             'survey_id',
108             'Appraisal Forms'),
109         'plan_id': fields.many2one('hr_evaluation.plan', 'Plan'),
110         'phase_id': fields.many2one('hr_evaluation.plan.phase', 'Phase'),
111         'state': fields.selection([
112             ('draft','Draft'),
113             ('wait','Plan In Progress'),
114             ('progress','Final Validation'),
115             ('done','Done'),
116             ('cancel','Cancelled'),
117         ], 'State', required=True,readonly=True)
118     }
119     _defaults = {
120         'date' : lambda *a: time.strftime('%Y-%m-%d'),
121         'state' : lambda *a: 'draft',
122     }
123
124     def button_plan_in_progress(self,cr, uid, ids, context):
125         self.write(cr,uid,ids,{'state':'wait'})
126         return True
127
128     def button_final_validation(self,cr, uid, ids, context):
129         self.write(cr,uid,ids,{'state':'progress'})
130         return True
131
132     def button_done(self,cr, uid, ids, context):
133         self.write(cr,uid,ids,{'state':'done'})
134         return True
135
136     def button_cancel(self,cr, uid, ids, context):
137         self.write(cr,uid,ids,{'state':'cancel'})
138         return True
139
140 hr_evaluation()
141
142