[IMP] hr_evaluation:improved views,code and description in terp

bzr revid: kum@tinyerp.co.in-20100311140844-rk6q0gm1jrts0j0e
This commit is contained in:
kum (Open ERP) 2010-03-11 19:38:44 +05:30
parent 0b99819879
commit 1c20ed0f6d
3 changed files with 86 additions and 51 deletions

View File

@ -26,13 +26,19 @@
"category" : "Generic Modules/Human Resources",
"website" : "http://www.openerp.com",
"depends" : ["hr",'hr_recruitment','survey'],
"description": "Ability to create employees evaluation.",
"description": """
Ability to create employees evaluation.
An evaluation can be created by employee for subordinates
juniors as well as his manager.The evaluation is done under a plan
in which various surveys can be created and it can be defined which
level of employee hierarchy fills what and final review and evaluation
is done by the manager.Every evaluation filled by the employees can be viewed
in the form of """,
"init_xml" : [],
"demo_xml" : ["hr_evaluation_demo.xml"],
"update_xml" : [
"security/ir.model.access.csv",
"hr_evaluation_view.xml",
"hr_evaluation_data.xml"],
"hr_evaluation_view.xml"],
"active": False,
"installable": True
}

View File

@ -20,8 +20,9 @@
##############################################################################
import time
from osv import fields, osv
from mx import DateTime as dt
from osv import fields, osv
import tools
from tools.translate import _
@ -31,7 +32,7 @@ class hr_evaluation_plan(osv.osv):
_columns = {
'name': fields.char("Evaluation Plan", size=64, required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'phase_ids' : fields.one2many('hr_evaluation.plan.phase', 'plan_id', 'Evaluation Phases'),
'phase_ids': fields.one2many('hr_evaluation.plan.phase', 'plan_id', 'Evaluation Phases'),
'month_first': fields.integer('First Evaluation After'),
'month_next': fields.integer('Next Evaluation After'),
'active': fields.boolean('Active')
@ -75,22 +76,44 @@ class hr_evaluation_plan_phase(osv.osv):
hr_evaluation_plan_phase()
class hr_employee(osv.osv):
_name = "hr.employee"
_inherit="hr.employee"
_columns = {
'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Evaluation Plan'),
'evaluation_date': fields.date('Next Evaluation', help="Date of the next evaluation"),
}
def onchange_evaluation_plan_id(self,cr,uid,ids,evaluation_plan_id,context={}):
evaluation_date = self.browse(cr, uid, ids)[0].evaluation_date or ''
def run_employee_evaluation(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
for id in self.browse(cr, uid, self.search(cr, uid, [],context=context),context=context):
if id.evaluation_plan_id and id.evaluation_date:
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"):
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)
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id},context)
return True
def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date, context={}):
evaluation_date = evaluation_date or False
evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
if evaluation_plan_id:
for evaluation_plan in evaluation_plan_obj.browse(cr,uid,[evaluation_plan_id]):
if not evaluation_date:
evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
else:
evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
flag = False
evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id],context=context)[0]
if not evaluation_date:
evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
flag = True
else:
if (dt.ISO.ParseAny(evaluation_date) + dt.RelativeDateTime(months = int(evaluation_plan.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"):
evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
flag = True
if ids and flag:
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id},context=context)
return {'value': {'evaluation_date':evaluation_date}}
def create(self, cr, uid, vals, context={}):
id = super(hr_employee, self).create(cr, uid, vals, context=context)
if vals.get('evaluation_plan_id', False):
self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']},context=context)
return id
hr_employee()
class hr_evaluation(osv.osv):
@ -132,18 +155,18 @@ class hr_evaluation(osv.osv):
employee_obj=self.pool.get('hr.employee')
evaluation_plan_id=''
if employee_id:
for employee in employee_obj.browse(cr,uid,[employee_id]):
for employee in employee_obj.browse(cr,uid,[employee_id],context=context):
if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id:
evaluation_plan_id=employee.evaluation_plan_id.id
employee_ids=employee_obj.search(cr,uid,[('parent_id','=',employee.id)])
employee_ids=employee_obj.search(cr,uid,[('parent_id','=',employee.id)],context=context)
return {'value': {'plan_id':evaluation_plan_id}}
def button_plan_in_progress(self,cr, uid, ids, context):
def button_plan_in_progress(self,cr, uid, ids, context={}):
employee_obj = self.pool.get('hr.employee')
hr_eval_inter_obj = self.pool.get('hr.evaluation.interview')
survey_request_obj = self.pool.get('survey.request')
curr_employee=self.browse(cr,uid, ids)[0].employee_id
child_employees=employee_obj.browse(cr,uid, employee_obj.search(cr,uid,[('parent_id','=',curr_employee.id)]))
curr_employee=self.browse(cr,uid, ids, context=context)[0].employee_id
child_employees=employee_obj.browse(cr,uid, employee_obj.search(cr,uid,[('parent_id','=',curr_employee.id)],context=context))
manager_employee=curr_employee.parent_id
for evaluation in self.browse(cr,uid,ids):
if evaluation and evaluation.plan_id:
@ -151,57 +174,58 @@ class hr_evaluation(osv.osv):
for phase in evaluation.plan_id.phase_ids:
if phase.action == "bottom-up":
for child in child_employees:
user = False
if child.user_id:
user = child.user_id.id
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')})
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)
if not phase.wait:
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context)
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
apprai_id.append(id)
elif phase.action == "top-down":
if manager_employee:
user = False
if manager_employee.user_id:
user = manager_employee.user_id.id
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')})
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)
if not phase.wait:
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context)
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
apprai_id.append(id)
elif phase.action == "self":
if curr_employee:
user = False
if curr_employee.user_id:
user = curr_employee.user_id.id
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')})
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)
if not phase.wait:
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context)
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
apprai_id.append(id)
elif phase.action == "final":
if manager_employee:
user = False
if manager_employee.user_id:
user = manager_employee.user_id.id
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')})
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)
if not phase.wait:
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context)
hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context)
apprai_id.append(id)
self.write(cr, uid, evaluation.id, {'survey_request_ids':[[6, 0, apprai_id]]})
self.write(cr,uid,ids,{'state':'wait'})
self.write(cr,uid,ids,{'state':'wait'},context=context)
return True
def button_final_validation(self,cr, uid, ids, context):
def button_final_validation(self,cr, uid, ids, context={}):
self.write(cr,uid,ids,{'state':'progress'})
request_obj = self.pool.get('hr.evaluation.interview')
for id in self.browse(cr, uid ,ids):
if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')])):
for id in self.browse(cr, uid ,ids,context=context):
if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')],context=context)):
raise osv.except_osv(_('Warning !'),_("You cannot change state, because some appraisal in waiting answer or draft state"))
return True
def button_done(self,cr, uid, ids, context):
self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')})
def button_done(self,cr, uid, ids, context={}):
self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context)
return True
def button_cancel(self,cr, uid, ids, context):
self.write(cr,uid,ids,{'state':'cancel'})
def button_cancel(self,cr, uid, ids, context={}):
self.write(cr,uid,ids,{'state':'cancel'}, context=context)
return True
hr_evaluation()
@ -218,7 +242,6 @@ class hr_evaluation_interview(osv.osv):
_inherits={'survey.request':'request_id'}
_description='Evaluation Interview'
_columns = {
'request_id': fields.many2one('survey.request','Request_id', ondelete='cascade'),
'user_to_review_id': fields.many2one('hr.employee', 'Employee'),
'evaluation_id' : fields.many2one('hr_evaluation.evaluation', 'Evaluation'),
@ -227,7 +250,7 @@ class hr_evaluation_interview(osv.osv):
'is_evaluation': lambda *a: True,
}
def survey_req_waiting_answer(self, cr, uid, ids, context):
def survey_req_waiting_answer(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, { 'state' : 'waiting_answer'})
# for id in self.browse(cr, uid, ids):
# if id.user_id and id.user_id.address_id and id.user_id.address_id and id.user_id.address_id.email:
@ -236,14 +259,14 @@ class hr_evaluation_interview(osv.osv):
# 'Invite to fill up Survey', msg)
return True
def survey_req_done(self, cr, uid, ids, context):
def survey_req_done(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, { 'state' : 'done'})
hr_eval_obj = self.pool.get('hr_evaluation.evaluation')
for id in self.browse(cr, uid, ids):
for id in self.browse(cr, uid, ids,context=context):
flag = False
wating_id = 0
tot_done_req = 0
records = self.pool.get("hr_evaluation.evaluation").browse(cr, uid, [id.evaluation_id.id])[0].survey_request_ids
records = self.pool.get("hr_evaluation.evaluation").browse(cr, uid, [id.evaluation_id.id],context=context)[0].survey_request_ids
for child in records:
if child.state == "draft" :
wating_id = child.id
@ -254,15 +277,15 @@ class hr_evaluation_interview(osv.osv):
tot_done_req += 1
if not flag and wating_id:
self.survey_req_waiting_answer(cr, uid, [wating_id], context)
hr_eval_obj.write(cr, uid, [id.evaluation_id.id], {'progress' :tot_done_req * 100 / len(records)})
hr_eval_obj.write(cr, uid, [id.evaluation_id.id], {'progress' :tot_done_req * 100 / len(records)}, context=context)
return True
def survey_req_draft(self, cr, uid, ids, arg):
self.write(cr, uid, ids, { 'state' : 'draft'})
def survey_req_draft(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, { 'state' : 'draft'}, context=context)
return True
def survey_req_cancel(self, cr, uid, ids, context):
self.write(cr, uid, ids, { 'state' : 'cancel'})
def survey_req_cancel(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, { 'state' : 'cancel'}, context=context)
return True
hr_evaluation_interview()

View File

@ -45,7 +45,7 @@
<menuitem name="Evaluations" parent="hr.menu_hr_root" id="menu_eval_hr" sequence="3"/>
<menuitem
name="Evaluations" parent="hr.menu_hr_configuration" id="menu_eval_hr_config" sequence="3"/>
name="Periodic Evaluations" parent="hr.menu_hr_configuration" id="menu_eval_hr_config" sequence="3"/>
<menuitem
parent="menu_eval_hr_config"
id="menu_open_view_hr_evaluation_plan_tree"
@ -109,7 +109,7 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Evaluation">
<field name="evaluation_plan_id" on_change="onchange_evaluation_plan_id(evaluation_plan_id)"/>
<field name="evaluation_plan_id" on_change="onchange_evaluation_plan_id(evaluation_plan_id, evaluation_date)"/>
<field name="evaluation_date"/>
</page>
</notebook>
@ -201,6 +201,12 @@
<field name="employee_id" widget="selection" select="1"/>
<field name="plan_id" widget="selection" select="1"/>
<field name="rating"/>
<newline/>
<group col='8' colspan='15' expand='1' string='Group by...'>
<filter string='Plan' icon="terp-stock" domain="[]" context="{'group_by' : 'plan_id'}" />
<filter string='state' icon="terp-stock" domain="[]" context="{'group_by' : 'state'}" />
</group>
</group>
</search>
</field>
@ -226,9 +232,9 @@
<group col="4" colspan="4">
<field name="survey_id" colspan="3"/>
<group colspan="1">
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action"
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response,'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action"
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done"
icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0,}" attrs="{'readonly':[('response','=',False)]}" />
</group>
</group>
@ -242,10 +248,10 @@
<separator string="State" colspan="4"/>
<group colspan="4" col="6">
<field name="state"/>
<button name="survey_req_draft" string="Set to Draft" states="cancel,done" type="object" icon="gtk-new"/>
<button name="survey_req_waiting_answer" string="Watting Answer" states="draft" type="object" icon="gtk-new"/>
<!--<button name="survey_req_draft" string="Set to Draft" states="cancel,done" type="object" icon="gtk-new"/>
<button name="survey_req_waiting_answer" string="Waiting Answer" states="draft" type="object" icon="gtk-new"/>
<button name="survey_req_done" string="Done" states="waiting_answer" type="object" icon="gtk-ok"/>
<button name="survey_req_cancel" string="Cancelled" states="waiting_answer" type="object" icon="gtk-cancel"/>
<button name="survey_req_cancel" string="Cancelled" states="waiting_answer" type="object" icon="gtk-cancel"/>-->
</group>
</form>
</field>
@ -263,7 +269,7 @@
<field name="response" readonly="1" invisible="True"/>
<button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel"
icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response, 'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="waiting_answer,done,cancel"
<button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done"
icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0}" attrs="{'readonly':[('response','=',False)]}" />
<field name="state"/>
</tree>