63
67
help="Send an anonymous summary to the employee"),
64
68
'wait': fields.boolean('Wait Previous Phases',
65
69
help="Check this box if you want to wait that all preceeding phases " +
66
"are finished before launching this phase.")
70
"are finished before launching this phase."),
71
'mail_feature': fields.boolean('Send mail for this phase',help="Check this box if you want to send mail to employees"+
72
"coming under this phase"),
73
'mail_body': fields.text('Email'),
74
'email_subject':fields.text('char')
70
77
'sequence' : lambda *a: 1,
78
'email_subject':_('''Regarding '''),
79
'mail_body' : lambda *a:_('''
82
Dear %(employee_name)s,
84
I am doing an evaluation regarding %(eval_name)s.
86
Kindly submit your response.
72
97
hr_evaluation_plan_phase()
74
99
class hr_employee(osv.osv):
100
_name = "hr.employee"
75
101
_inherit="hr.employee"
77
103
'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Evaluation Plan'),
78
104
'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation"),
80
def onchange_evaluation_plan_id(self, *args):
81
# return the right evaluation date
107
def run_employee_evaluation(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
108
for id in self.browse(cr, uid, self.search(cr, uid, [],context=context),context=context):
109
if id.evaluation_plan_id and id.evaluation_date:
110
if (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months = int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"):
111
self.write(cr, uid, id.id, {'evaluation_date' : (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')},context=context)
112
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id},context)
115
def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date, context={}):
116
evaluation_date = evaluation_date or False
117
evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
118
if evaluation_plan_id:
120
evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id],context=context)[0]
121
if not evaluation_date:
122
evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
125
if (dt.ISO.ParseAny(evaluation_date) + dt.RelativeDateTime(months = int(evaluation_plan.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"):
126
evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
129
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id},context=context)
130
return {'value': {'evaluation_date':evaluation_date}}
132
def create(self, cr, uid, vals, context={}):
133
id = super(hr_employee, self).create(cr, uid, vals, context=context)
134
if vals.get('evaluation_plan_id', False):
135
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']},context=context)
85
140
class hr_evaluation(osv.osv):
101
155
('3','Exceeds expectations'),
102
156
('4','Significantly exceeds expectations'),
103
157
], "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',
109
'plan_id': fields.many2one('hr_evaluation.plan', 'Plan'),
110
'phase_id': fields.many2one('hr_evaluation.plan.phase', 'Phase'),
158
'survey_request_ids': fields.one2many('hr.evaluation.interview','evaluation_id','Appraisal Forms'),
159
'plan_id': fields.many2one('hr_evaluation.plan', 'Plan', required=True),
111
160
'state': fields.selection([
112
161
('draft','Draft'),
113
162
('wait','Plan In Progress'),
114
163
('progress','Final Validation'),
116
165
('cancel','Cancelled'),
117
], 'State', required=True,readonly=True)
166
], 'State', required=True,readonly=True),
167
'date_close': fields.date('Ending Date'),
168
'progress' : fields.float("Progress"),
120
'date' : lambda *a: time.strftime('%Y-%m-%d'),
171
'date' : lambda *a: (dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d'),
121
172
'state' : lambda *a: 'draft',
124
def button_plan_in_progress(self,cr, uid, ids, context):
125
self.write(cr,uid,ids,{'state':'wait'})
175
def onchange_employee_id(self,cr,uid,ids,employee_id,context={}):
176
employee_obj=self.pool.get('hr.employee')
177
evaluation_plan_id=''
179
for employee in employee_obj.browse(cr,uid,[employee_id],context=context):
180
if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id:
181
evaluation_plan_id=employee.evaluation_plan_id.id
182
employee_ids=employee_obj.search(cr,uid,[('parent_id','=',employee.id)],context=context)
183
return {'value': {'plan_id':evaluation_plan_id}}
185
def button_plan_in_progress(self,cr, uid, ids, context={}):
186
user_obj = self.pool.get('res.users')
187
employee_obj = self.pool.get('hr.employee')
188
hr_eval_inter_obj = self.pool.get('hr.evaluation.interview')
189
survey_request_obj = self.pool.get('survey.request')
190
hr_eval_plan_obj = self.pool.get('hr_evaluation.plan.phase')
191
curr_employee=self.browse(cr,uid, ids, context=context)[0].employee_id
192
child_employees=employee_obj.browse(cr,uid, employee_obj.search(cr,uid,[('parent_id','=',curr_employee.id)],context=context))
193
manager_employee=curr_employee.parent_id
194
for evaluation in self.browse(cr,uid,ids):
195
if evaluation and evaluation.plan_id:
197
for phase in evaluation.plan_id.phase_ids:
198
if phase.action == "bottom-up":
199
for child in child_employees:
202
user = child.user_id.id
203
id = hr_eval_inter_obj.create(cr, uid, {'evaluation_id':evaluation.id ,'user_id' : user,'survey_id' : phase.survey_id.id, 'user_to_review_id' : child.id, 'date_deadline' :(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d')},context=context)
205
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
206
if phase.mail_feature:
207
src = tools.config.options['email_from']
208
user_obj_id = user_obj.browse(cr,uid,uid)
210
'employee_name':child.name,
211
'user_signature':curr_employee.name,
212
# 'company_name':user_obj_id.company_id.name,
213
'eval_name':phase.survey_id.title,
214
'date':time.strftime('%Y-%m-%d'),
216
mailbody = hr_eval_plan_obj.read(cr,uid,phase.id,['mail_body','email_subject'],context=context)
217
body = mailbody['mail_body']%val
218
sub = mailbody['email_subject']+phase.survey_id.title
219
dest=[child.work_email]
221
tools.email_send(src,dest,sub,body)
224
elif phase.action == "top-down":
227
if manager_employee.user_id:
228
user = manager_employee.user_id.id
229
id = hr_eval_inter_obj.create(cr, uid, {'evaluation_id':evaluation.id,'user_id': user ,'survey_id' : phase.survey_id.id, 'user_to_review_id' :manager_employee.id, 'date_deadline' :(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d')},context=context)
231
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
232
if phase.mail_feature:
233
val.update({'employee_name':manager_employee.name})
234
mailbody = hr_eval_plan_obj.read(cr,uid,phase.id,['mail_body'],context=context)
235
body = mailbody['mail_body']%val
236
dest = [manager_employee.work_email]
238
tools.email_send(src,dest,sub,body)
240
elif phase.action == "self":
243
if curr_employee.user_id:
244
user = curr_employee.user_id.id
245
id = hr_eval_inter_obj.create(cr, uid, {'evaluation_id':evaluation.id,'user_id' : user, 'survey_id' : phase.survey_id.id, 'user_to_review_id' :curr_employee.id, 'date_deadline' :(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d')},context=context)
247
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
249
elif phase.action == "final":
252
if manager_employee.user_id:
253
user = manager_employee.user_id.id
254
id = hr_eval_inter_obj.create(cr, uid, {'evaluation_id':evaluation.id,'user_id' : user, 'survey_id' : phase.survey_id.id, 'user_to_review_id' :manager_employee.id, 'date_deadline' :(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d')},context=context)
256
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
258
self.write(cr, uid, evaluation.id, {'survey_request_ids':[[6, 0, apprai_id]]})
259
self.write(cr,uid,ids,{'state':'wait'},context=context)
128
def button_final_validation(self,cr, uid, ids, context):
262
def button_final_validation(self,cr, uid, ids, context={}):
129
263
self.write(cr,uid,ids,{'state':'progress'})
132
def button_done(self,cr, uid, ids, context):
133
self.write(cr,uid,ids,{'state':'done'})
136
def button_cancel(self,cr, uid, ids, context):
137
self.write(cr,uid,ids,{'state':'cancel'})
264
request_obj = self.pool.get('hr.evaluation.interview')
265
for id in self.browse(cr, uid ,ids,context=context):
266
if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')],context=context)):
267
raise osv.except_osv(_('Warning !'),_("You cannot change state, because some appraisal in waiting answer or draft state"))
270
def button_done(self,cr, uid, ids, context={}):
271
self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context)
274
def button_cancel(self,cr, uid, ids, context={}):
275
self.write(cr,uid,ids,{'state':'cancel'}, context=context)
280
class survey_request(osv.osv):
281
_inherit="survey.request"
283
'is_evaluation':fields.boolean('Is Evaluation?'),
288
class hr_evaluation_interview(osv.osv):
289
_name='hr.evaluation.interview'
290
_inherits={'survey.request':'request_id'}
291
_description='Evaluation Interview'
293
'request_id': fields.many2one('survey.request','Request_id', ondelete='cascade'),
294
'user_to_review_id': fields.many2one('hr.employee', 'Employee'),
295
'evaluation_id' : fields.many2one('hr_evaluation.evaluation', 'Evaluation'),
298
'is_evaluation': lambda *a: True,
301
def survey_req_waiting_answer(self, cr, uid, ids, context={}):
302
self.write(cr, uid, ids, { 'state' : 'waiting_answer'})
303
# for id in self.browse(cr, uid, ids):
305
# if id.user_to_review_id and id.user_to_review_id.work_email:
306
# msg = " Hello %s, \n\n We are inviting you for %s survey. \n\n Thanks," %(id.user_to_review_id.name, id.survey_id.title)
307
# tools.email_send(tools.config['email_from'], [id.user_to_review_id.work_email],\
308
# 'Invite to fill up Survey', msg)
311
def survey_req_done(self, cr, uid, ids, context={}):
312
self.write(cr, uid, ids, { 'state' : 'done'})
313
hr_eval_obj = self.pool.get('hr_evaluation.evaluation')
314
for id in self.browse(cr, uid, ids,context=context):
318
records = self.pool.get("hr_evaluation.evaluation").browse(cr, uid, [id.evaluation_id.id],context=context)[0].survey_request_ids
319
for child in records:
320
if child.state == "draft" :
323
if child.state != "done":
327
if not flag and wating_id:
328
self.survey_req_waiting_answer(cr, uid, [wating_id], context)
329
hr_eval_obj.write(cr, uid, [id.evaluation_id.id], {'progress' :tot_done_req * 100 / len(records)}, context=context)
332
def survey_req_draft(self, cr, uid, ids, context={}):
333
self.write(cr, uid, ids, { 'state' : 'draft'}, context=context)
336
def survey_req_cancel(self, cr, uid, ids, context={}):
337
self.write(cr, uid, ids, { 'state' : 'cancel'}, context=context)
340
hr_evaluation_interview()
342
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:1