1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
23 from osv import fields, osv
24 from mx import DateTime as dt
26 class hr_evaluation_plan(osv.osv):
27 _name = "hr_evaluation.plan"
28 _description = "Evaluation Plan"
30 'name': fields.char("Evaluation Plan", size=64, required=True),
31 'company_id': fields.many2one('res.company', 'Company', required=True),
32 'phase_ids' : fields.one2many('hr_evaluation.plan.phase', 'plan_id', 'Evaluation Phases'),
33 'month_first': fields.integer('First Evaluation After'),
34 'month_next': fields.integer('Next Evaluation After'),
35 'active': fields.boolean('Active')
38 'active' : lambda *a: True,
42 class hr_evaluation_plan_phase(osv.osv):
43 _name = "hr_evaluation.plan.phase"
44 _description = "Evaluation Plan Phase"
47 'name': fields.char("Phase", size=64, required=True),
48 'sequence': fields.integer("Sequence"),
49 'company_id': fields.related('plan_id','company_id',type='many2one',relation='res.company',string='Company',store=True),
50 'plan_id': fields.many2one('hr_evaluation.plan','Evaluation Plan', required=True, ondelete='cascade'),
51 'action': fields.selection([
52 ('top-down','Top-Down Appraisal Requests'),
53 ('bottom-up','Bottom-Up Appraisal Requests'),
54 ('self','Self Appraisal Requests'),
55 ('final','Final Interview')], 'Action', required=True),
56 'survey_id': fields.many2one('survey','Appraisal Form',required=True),
57 'send_answer_manager': fields.boolean('All Answers',
58 help="Send all answers to the manager"),
59 'send_answer_employee': fields.boolean('All Answers',
60 help="Send all answers to the employee"),
61 'send_anonymous_manager': fields.boolean('Anonymous Summary',
62 help="Send an anonymous summary to the manager"),
63 'send_anonymous_employee': fields.boolean('Anonymous Summary',
64 help="Send an anonymous summary to the employee"),
65 'wait': fields.boolean('Wait Previous Phases',
66 help="Check this box if you want to wait that all preceeding phases " +
67 "are finished before launching this phase.")
71 'sequence' : lambda *a: 1,
73 hr_evaluation_plan_phase()
75 class hr_employee(osv.osv):
76 _inherit="hr.employee"
78 'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Evaluation Plan'),
79 'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation",readonly=True),
82 def onchange_evaluation_plan_id(self,cr,uid,ids,evaluation_plan_id,context={}):
83 evaluation_date = self.browse(cr, uid, ids)[0].evaluation_date or ''
84 evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
85 if evaluation_plan_id:
86 for evaluation_plan in evaluation_plan_obj.browse(cr,uid,[evaluation_plan_id]):
87 if not evaluation_date:
88 evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
90 evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
91 return {'value': {'evaluation_date':evaluation_date}}
94 class hr_evaluation_interview(osv.osv):
95 _name = "hr.evaluation.interview"
96 _inherit = "survey.request"
98 def default_get(self, cr, uid, fields, context={}):
99 data = super(hr_evaluation_interview, self).default_get(cr, uid, fields, context)
100 if context.has_key('phase_id'):
101 data['survey_id'] =self.pool.get('hr_evaluation.plan.phase').browse(cr, uid, context['phase_id']).survey_id.id
105 'user_to_review_id': fields.many2one('hr.employee', 'Employee'),
107 hr_evaluation_interview()
109 class hr_evaluation(osv.osv):
110 _name = "hr_evaluation.evaluation"
111 _description = "Employee Evaluation"
112 _rec_name = 'employee_id'
114 'date': fields.date("Evaluation Deadline", required=True),
115 'employee_id': fields.many2one('hr.employee', "Employee", required=True),
116 'note_summary': fields.text('Evaluation Summary'),
117 'note_action': fields.text('Action Plan',
118 help="If the evaluation does not meet the expectations, you can propose"+
120 'rating': fields.selection([
121 ('0','Significantly bellow expectations'),
122 ('1','Did not meet expectations'),
123 ('2','Meet expectations'),
124 ('3','Exceeds expectations'),
125 ('4','Significantly exceeds expectations'),
126 ], "Overall Rating", help="This is the overall rating on that summarize the evaluation"),
127 'survey_request_ids': fields.many2many('hr.evaluation.interview',
128 'hr_evaluation_evaluation_requests',
132 'plan_id': fields.many2one('hr_evaluation.plan', 'Plan', required=True),
133 'state': fields.selection([
135 ('wait','Plan In Progress'),
136 ('progress','Final Validation'),
138 ('cancel','Cancelled'),
139 ], 'State', required=True,readonly=True),
140 'date_close': fields.date('Ending Date')
143 'date' : lambda *a: time.strftime('%Y-%m-%d'),
144 'state' : lambda *a: 'draft',
147 def button_plan_in_progress(self,cr, uid, ids, context):
148 self.write(cr,uid,ids,{'state':'wait'})
151 def button_final_validation(self,cr, uid, ids, context):
152 self.write(cr,uid,ids,{'state':'progress'})
155 def button_done(self,cr, uid, ids, context):
156 self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')})
159 def button_cancel(self,cr, uid, ids, context):
160 self.write(cr,uid,ids,{'state':'cancel'})