50
50
'name': fields.char("Phase", size=64, required=True),
51
51
'sequence': fields.integer("Sequence"),
52
'company_id': fields.related('plan_id','company_id',type='many2one',relation='res.company',string='Company',store=True),
52
'company_id': fields.related('plan_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
53
53
'plan_id': fields.many2one('hr_evaluation.plan','Evaluation Plan', required=True, ondelete='cascade'),
54
54
'action': fields.selection([
55
55
('top-down','Top-Down Appraisal Requests'),
68
68
'wait': fields.boolean('Wait Previous Phases',
69
69
help="Check this box if you want to wait that all preceeding phases " +
70
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"+
71
'mail_feature': fields.boolean('Send mail for this phase', help="Check this box if you want to send mail to employees"+
72
72
"coming under this phase"),
73
73
'mail_body': fields.text('Email'),
74
74
'email_subject':fields.text('char')
107
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):
108
for id in self.browse(cr, uid, self.search(cr, uid, [], context=context), context=context):
109
109
if id.evaluation_plan_id and id.evaluation_date:
110
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)
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
115
def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date, context={}):
117
117
evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
118
118
if evaluation_plan_id:
120
evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id],context=context)[0]
120
evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id], context=context)[0]
121
121
if not evaluation_date:
122
122
evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
126
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)
129
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id}, context=context)
130
130
return {'value': {'evaluation_date':evaluation_date}}
132
132
def create(self, cr, uid, vals, context={}):
133
133
id = super(hr_employee, self).create(cr, uid, vals, context=context)
134
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)
135
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']}, context=context)
163
163
('progress','Final Validation'),
165
165
('cancel','Cancelled'),
166
], 'State', required=True,readonly=True),
166
], 'State', required=True, readonly=True),
167
167
'date_close': fields.date('Ending Date'),
168
168
'progress' : fields.float("Progress"),
172
172
'state' : lambda *a: 'draft',
175
def onchange_employee_id(self,cr,uid,ids,employee_id,context={}):
175
def onchange_employee_id(self, cr, uid, ids, employee_id, context={}):
176
176
employee_obj=self.pool.get('hr.employee')
177
177
evaluation_plan_id=''
179
for employee in employee_obj.browse(cr,uid,[employee_id],context=context):
179
for employee in employee_obj.browse(cr, uid, [employee_id], context=context):
180
180
if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id:
181
181
evaluation_plan_id=employee.evaluation_plan_id.id
182
employee_ids=employee_obj.search(cr,uid,[('parent_id','=',employee.id)],context=context)
182
employee_ids=employee_obj.search(cr, uid, [('parent_id','=',employee.id)], context=context)
183
183
return {'value': {'plan_id':evaluation_plan_id}}
185
def button_plan_in_progress(self,cr, uid, ids, context={}):
185
def button_plan_in_progress(self, cr, uid, ids, context={}):
187
for evaluation in self.browse(cr,uid,ids, context):
187
for evaluation in self.browse(cr, uid, ids, context):
189
189
for phase in evaluation.plan_id.phase_ids:
223
223
sub = phase.email_subject
224
224
dest = [child.work_email]
226
tools.email_send(src,dest,sub,body)
226
tools.email_send(src, dest, sub, body)
228
self.write(cr,uid,ids,{'state':'wait'},context=context)
228
self.write(cr, uid, ids, {'state':'wait'}, context=context)
231
def button_final_validation(self,cr, uid, ids, context={}):
232
self.write(cr,uid,ids,{'state':'progress'})
231
def button_final_validation(self, cr, uid, ids, context={}):
232
self.write(cr, uid, ids, {'state':'progress'})
233
233
request_obj = self.pool.get('hr.evaluation.interview')
234
234
for id in self.browse(cr, uid ,ids,context=context):
235
235
if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')],context=context)):
240
240
self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context)
243
def button_cancel(self,cr, uid, ids, context={}):
244
self.write(cr,uid,ids,{'state':'cancel'}, context=context)
243
def button_cancel(self, cr, uid, ids, context={}):
244
self.write(cr, uid, ids,{'state':'cancel'}, context=context)