Appraisal score allowed to be fraction
This commit is contained in:
parent
fdb0e362a7
commit
e8475f9b85
@ -1,145 +1,150 @@
|
||||
cur_frm.add_fetch('employee', 'company', 'company');
|
||||
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
|
||||
if(doc.employee) cur_frm.cscript.employee(doc,cdt,cdn);
|
||||
if(doc.amended_from && doc.__islocal) cur_frm.cscript.refresh_appraisal_details(doc, cdt, cdn);
|
||||
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
|
||||
if(doc.employee) cur_frm.cscript.employee(doc,cdt,cdn);
|
||||
if(doc.amended_from && doc.__islocal) cur_frm.cscript.refresh_appraisal_details(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
if(user == doc.kra_approver && doc.status == 'Submitted') unhide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
else hide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
|
||||
if(!doc.docstatus) unhide_field('Fetch Template');
|
||||
else hide_field('Fetch Template');
|
||||
if(user == doc.kra_approver && doc.status == 'Submitted') unhide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
else hide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
|
||||
if(!doc.docstatus) unhide_field('Fetch Template');
|
||||
else hide_field('Fetch Template');
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.refresh_appraisal_details = function(doc, cdt, cdn){
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
for(var i = 0; i<val.length; i++){
|
||||
set_multiple('Appraisal Detail', val[i].name, {'target_achieved':'', 'score':'', 'scored_earned':''}, 'appraisal_details');
|
||||
}
|
||||
doc.total_score = '';
|
||||
refresh_field('appraisal_details');
|
||||
refresh_field('total_score');
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
for(var i = 0; i<val.length; i++){
|
||||
set_multiple('Appraisal Detail', val[i].name, {'target_achieved':'', 'score':'', 'scored_earned':''}, 'appraisal_details');
|
||||
}
|
||||
doc.total_score = '';
|
||||
refresh_field('appraisal_details');
|
||||
refresh_field('total_score');
|
||||
}
|
||||
|
||||
cur_frm.cscript.employee = function(doc,cdt,cdn){
|
||||
if(doc.employee){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'set_approver','', function(r,rt){
|
||||
if(r.message){
|
||||
doc.employee_name = r.message['emp_nm'];
|
||||
get_field(doc.doctype, 'kra_approver' , doc.name).options = r.message['app_lst'];
|
||||
refresh_many(['kra_approver','employee_name']);
|
||||
}
|
||||
});
|
||||
}
|
||||
if(doc.employee){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'set_approver','', function(r,rt){
|
||||
if(r.message){
|
||||
doc.employee_name = r.message['emp_nm'];
|
||||
get_field(doc.doctype, 'kra_approver' , doc.name).options = r.message['app_lst'];
|
||||
refresh_many(['kra_approver','employee_name']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Calculate Total Score'] = function(doc,cdt,cdn){
|
||||
//get_server_fields('calculate_total','','',doc,cdt,cdn,1);
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
var total =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total = flt(total)+flt(val[i].score_earned)
|
||||
}
|
||||
doc.total_score = flt(total)
|
||||
refresh_field('total_score')
|
||||
//get_server_fields('calculate_total','','',doc,cdt,cdn,1);
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
var total =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total = flt(total)+flt(val[i].score_earned)
|
||||
}
|
||||
doc.total_score = flt(total)
|
||||
refresh_field('total_score')
|
||||
}
|
||||
|
||||
/*cur_frm.cscript['Declare Completed'] = function(doc,cdt,cdn){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'declare_completed','', function(r,rt){
|
||||
if(r.message){
|
||||
refresh_field('Status');
|
||||
cur_frm.cscript.refresh(doc,cdt,cdn);
|
||||
}
|
||||
});
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'declare_completed','', function(r,rt){
|
||||
if(r.message){
|
||||
refresh_field('Status');
|
||||
cur_frm.cscript.refresh(doc,cdt,cdn);
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
cur_frm.cscript['Declare Completed'] = function(doc,cdt,cdn){
|
||||
var declare_completed_dialog;
|
||||
|
||||
set_declare_completed_dialog = function() {
|
||||
declare_completed_dialog = new Dialog(400, 200, 'Declare Completed');
|
||||
declare_completed_dialog.make_body([
|
||||
['HTML', 'Message', '<div class = "comment">You wont be able to do any changes after declaring this Appraisal as completed. Are you sure, you want to declare it as completed ?</div>'],
|
||||
['HTML', 'Response', '<div class = "comment" id="declare_completed_dialog_response"></div>'],
|
||||
['HTML', 'Declare Completed', '<div></div>']
|
||||
]);
|
||||
|
||||
var declare_completed_btn1 = $a($i(declare_completed_dialog.widgets['Declare Completed']), 'button', 'button');
|
||||
declare_completed_btn1.innerHTML = 'Yes';
|
||||
declare_completed_btn1.onclick = function(){ declare_completed_dialog.add(); }
|
||||
|
||||
var declare_completed_btn2 = $a($i(declare_completed_dialog.widgets['Declare Completed']), 'button', 'button');
|
||||
declare_completed_btn2.innerHTML = 'No';
|
||||
$y(declare_completed_btn2,{marginLeft:'4px'});
|
||||
declare_completed_btn2.onclick = function(){ declare_completed_dialog.hide();}
|
||||
|
||||
declare_completed_dialog.onshow = function() {
|
||||
$i('declare_completed_dialog_response').innerHTML = '';
|
||||
}
|
||||
|
||||
declare_completed_dialog.refresh_dt = function(){
|
||||
cur_frm.cscript.refresh(this.doc, this.cdt, this.cdn);
|
||||
msgprint("refersh done");
|
||||
$c('webnotes.widgets.form.form_header.refresh_labels',this.doc,function(r,rt){});
|
||||
}
|
||||
|
||||
declare_completed_dialog.add = function() {
|
||||
// sending...
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Processing...';
|
||||
var m_arg = user+ '~~' + this.msg_nm_lst;
|
||||
|
||||
$c_obj(make_doclist(this.doc.doctype, this.doc.name),'declare_completed','', function(r,rt){
|
||||
|
||||
if(r.message.status == 'Completed'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Done';
|
||||
refresh_field('status');
|
||||
declare_completed_dialog.refresh_dt();
|
||||
hide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
declare_completed_dialog.hide();
|
||||
}
|
||||
else if(r.message.status == 'Incomplete'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Incomplete Appraisal';
|
||||
}
|
||||
else if(r.message.status == 'No Score'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Calculate total score';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(!declare_completed_dialog){
|
||||
set_declare_completed_dialog();
|
||||
}
|
||||
declare_completed_dialog.doc = doc;
|
||||
declare_completed_dialog.cdt = cdt;
|
||||
declare_completed_dialog.cdn = cdn;
|
||||
declare_completed_dialog.show();
|
||||
var declare_completed_dialog;
|
||||
|
||||
set_declare_completed_dialog = function() {
|
||||
declare_completed_dialog = new Dialog(400, 200, 'Declare Completed');
|
||||
declare_completed_dialog.make_body([
|
||||
['HTML', 'Message', '<div class = "comment">You wont be able to do any changes after declaring this Appraisal as completed. Are you sure, you want to declare it as completed ?</div>'],
|
||||
['HTML', 'Response', '<div class = "comment" id="declare_completed_dialog_response"></div>'],
|
||||
['HTML', 'Declare Completed', '<div></div>']
|
||||
]);
|
||||
|
||||
var declare_completed_btn1 = $a($i(declare_completed_dialog.widgets['Declare Completed']), 'button', 'button');
|
||||
declare_completed_btn1.innerHTML = 'Yes';
|
||||
declare_completed_btn1.onclick = function(){ declare_completed_dialog.add(); }
|
||||
|
||||
var declare_completed_btn2 = $a($i(declare_completed_dialog.widgets['Declare Completed']), 'button', 'button');
|
||||
declare_completed_btn2.innerHTML = 'No';
|
||||
$y(declare_completed_btn2,{marginLeft:'4px'});
|
||||
declare_completed_btn2.onclick = function(){ declare_completed_dialog.hide();}
|
||||
|
||||
declare_completed_dialog.onshow = function() {
|
||||
$i('declare_completed_dialog_response').innerHTML = '';
|
||||
}
|
||||
|
||||
declare_completed_dialog.refresh_dt = function(){
|
||||
cur_frm.cscript.refresh(this.doc, this.cdt, this.cdn);
|
||||
msgprint("refersh done");
|
||||
$c('webnotes.widgets.form.form_header.refresh_labels',this.doc,function(r,rt){});
|
||||
}
|
||||
|
||||
declare_completed_dialog.add = function() {
|
||||
// sending...
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Processing...';
|
||||
var m_arg = user+ '~~' + this.msg_nm_lst;
|
||||
|
||||
$c_obj(make_doclist(this.doc.doctype, this.doc.name),'declare_completed','', function(r,rt){
|
||||
|
||||
if(r.message.status == 'Completed'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Done';
|
||||
refresh_field('status');
|
||||
declare_completed_dialog.refresh_dt();
|
||||
hide_field(['Update', 'Declare Completed', 'Calculate Total Score']);
|
||||
declare_completed_dialog.hide();
|
||||
}
|
||||
else if(r.message.status == 'Incomplete'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Incomplete Appraisal';
|
||||
}
|
||||
else if(r.message.status == 'No Score'){
|
||||
$i('declare_completed_dialog_response').innerHTML = 'Calculate total score';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(!declare_completed_dialog){
|
||||
set_declare_completed_dialog();
|
||||
}
|
||||
declare_completed_dialog.doc = doc;
|
||||
declare_completed_dialog.cdt = cdt;
|
||||
declare_completed_dialog.cdn = cdn;
|
||||
declare_completed_dialog.show();
|
||||
}
|
||||
|
||||
cur_frm.cscript.score = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.score){
|
||||
total = flt(d.per_weightage*d.score)/100;
|
||||
d.score_earned = total.toPrecision(2);
|
||||
refresh_field('score_earned', d.name, 'appraisal_details');
|
||||
}
|
||||
else{
|
||||
d.score_earned = '';
|
||||
refresh_field('score_earned', d.name, 'appraisal_details');
|
||||
}
|
||||
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.score){
|
||||
if (flt(d.score) > 5) {
|
||||
msgprint("Score must be less than or equal to 5");
|
||||
d.score = 0;
|
||||
refresh_field('score', d.name, 'appraisal_details');
|
||||
}
|
||||
total = flt(d.per_weightage*d.score)/100;
|
||||
d.score_earned = total.toPrecision(2);
|
||||
refresh_field('score_earned', d.name, 'appraisal_details');
|
||||
}
|
||||
else{
|
||||
d.score_earned = '';
|
||||
refresh_field('score_earned', d.name, 'appraisal_details');
|
||||
}
|
||||
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.calculate_total = function(doc,cdt,cdn){
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
var total =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total = flt(total)+flt(val[i].score_earned);
|
||||
}
|
||||
doc.total_score = flt(total);
|
||||
refresh_field('total_score');
|
||||
var val = getchildren('Appraisal Detail', doc.name, 'appraisal_details', doc.doctype);
|
||||
var total =0;
|
||||
for(var i = 0; i<val.length; i++){
|
||||
total = flt(total)+flt(val[i].score_earned);
|
||||
}
|
||||
doc.total_score = flt(total);
|
||||
refresh_field('total_score');
|
||||
}
|
||||
|
@ -18,130 +18,131 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def get_employee_name(self):
|
||||
emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
emp_nm= emp_nm and emp_nm[0][0] or ''
|
||||
self.doc.employee_name = emp_nm
|
||||
return emp_nm
|
||||
|
||||
def fetch_kra(self):
|
||||
if not self.doc.kra_template:
|
||||
msgprint("Please select KRA Template to be be fetched")
|
||||
raise Exception
|
||||
self.doc.clear_table(self.doclist,'appraisal_details')
|
||||
get_obj('DocType Mapper', 'KRA Template-Appraisal').dt_map('KRA Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['KRA Template','Appraisal'],['KRA Sheet', 'Appraisal Detail']]")
|
||||
|
||||
def validate_dates(self):
|
||||
if getdate(self.doc.start_date) > getdate(self.doc.end_date):
|
||||
msgprint("End Date can not be less than Start Date")
|
||||
raise Exception
|
||||
|
||||
def validate_existing_appraisal(self):
|
||||
chk = sql("select name from `tabAppraisal` where employee=%s and (status='Submitted' or status='Completed') and ((start_date>=%s and start_date<=%s) or (end_date>=%s and end_date<=%s))",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date))
|
||||
if chk:
|
||||
msgprint("You have already created Appraisal "+cstr(chk[0][0])+" in the current date range for employee "+cstr(self.doc.employee_name))
|
||||
raise Exception
|
||||
|
||||
def validate_curr_appraisal(self):
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if d.target_achieved or d.score:
|
||||
if self.doc.status == 'Draft':
|
||||
msgprint("Target achieved or Score can be added only for submitted Appraisal")
|
||||
raise Exception
|
||||
elif self.doc.status == 'Submitted' and session['user'] != self.doc.kra_approver:
|
||||
msgprint("Target achieved or Score can be added only by Appraisal Approver")
|
||||
raise Exception
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
|
||||
ysd=fy and fy[0][0] or ""
|
||||
yed=add_days(str(ysd),365)
|
||||
if str(self.doc.start_date) < str(ysd) or str(self.doc.start_date) > str(yed) or str(self.doc.end_date) < str(ysd) or str(self.doc.end_date) > str(yed):
|
||||
msgprint("Appraisal date range is not within the Fiscal Year selected")
|
||||
raise Exception
|
||||
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.validate_existing_appraisal()
|
||||
self.validate_curr_appraisal()
|
||||
self.validate_fiscal_year()
|
||||
|
||||
def set_approver(self):
|
||||
ret={}
|
||||
approver_lst =[]
|
||||
emp_nm = self.get_employee_name()
|
||||
approver_lst1 = get_obj('Authorization Control').get_approver_name(self.doc.doctype,0,self)
|
||||
if approver_lst1:
|
||||
approver_lst=approver_lst1
|
||||
else:
|
||||
approver_lst = [x[0] for x in sql("select distinct name from `tabProfile` where enabled=1 and name!='Administrator' and name!='Guest' and docstatus!=2")]
|
||||
ret = {'app_lst':"\n" + "\n".join(approver_lst), 'emp_nm':cstr(emp_nm)}
|
||||
return ret
|
||||
|
||||
def calculate_total(self):
|
||||
total = 0
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if d.score:
|
||||
total = total + flt(d.score_earned)
|
||||
ret={'total_score':flt(total)}
|
||||
return ret
|
||||
|
||||
def declare_completed(self):
|
||||
ret={}
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if not d.target_achieved or not d.score or not d.score_earned:
|
||||
msgprint("Please add 'Target Achieved' and 'Score' for all KPI")
|
||||
ret = {'status':'Incomplete'}
|
||||
return ret
|
||||
|
||||
if not self.doc.total_score:
|
||||
msgprint("Please calculate total score using button 'Calculate Total Score'")
|
||||
ret = {'status':'No Score'}
|
||||
return ret
|
||||
self.update_appraisal()
|
||||
#set(self.doc, 'status', 'Completed')
|
||||
ret = {'status':'Completed'}
|
||||
return ret
|
||||
|
||||
def update_appraisal(self):
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if not d.kra or not d.per_weightage:
|
||||
msgprint("Please remove the extra blank row added")
|
||||
raise Exception
|
||||
d.save()
|
||||
if self.doc.total_score:
|
||||
set(self.doc,'total_score',self.doc.total_score)
|
||||
|
||||
def on_update(self):
|
||||
set(self.doc, 'status', 'Draft')
|
||||
|
||||
def validate_total_weightage(self):
|
||||
total_w = 0
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
total_w = flt(total_w) + flt(d.per_weightage)
|
||||
|
||||
if flt(total_w)>100 or flt(total_w)<100:
|
||||
msgprint("Total of weightage assigned to KPI is "+cstr(total_w)+".It should be 100(%)")
|
||||
raise Exception
|
||||
|
||||
def validate_appraisal_detail(self):
|
||||
if not self.doc.kra_approver:
|
||||
msgprint("Please mention the name of Approver")
|
||||
raise Exception
|
||||
|
||||
if not getlist(self.doclist, 'appraisal_details'):
|
||||
msgprint("Please add KRA Details")
|
||||
raise Exception
|
||||
|
||||
self.validate_total_weightage()
|
||||
|
||||
def on_submit(self):
|
||||
self.validate_appraisal_detail()
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
set(self.doc, 'status', 'Cancelled')
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def get_employee_name(self):
|
||||
emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
emp_nm= emp_nm and emp_nm[0][0] or ''
|
||||
self.doc.employee_name = emp_nm
|
||||
return emp_nm
|
||||
|
||||
def fetch_kra(self):
|
||||
if not self.doc.kra_template:
|
||||
msgprint("Please select KRA Template to be be fetched")
|
||||
raise Exception
|
||||
self.doc.clear_table(self.doclist,'appraisal_details')
|
||||
get_obj('DocType Mapper', 'KRA Template-Appraisal').dt_map('KRA Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['KRA Template','Appraisal'],['KRA Sheet', 'Appraisal Detail']]")
|
||||
|
||||
def validate_dates(self):
|
||||
if getdate(self.doc.start_date) > getdate(self.doc.end_date):
|
||||
msgprint("End Date can not be less than Start Date")
|
||||
raise Exception
|
||||
|
||||
def validate_existing_appraisal(self):
|
||||
chk = sql("select name from `tabAppraisal` where employee=%s and (status='Submitted' or status='Completed') and ((start_date>=%s and start_date<=%s) or (end_date>=%s and end_date<=%s))",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date))
|
||||
if chk:
|
||||
msgprint("You have already created Appraisal "+cstr(chk[0][0])+" in the current date range for employee "+cstr(self.doc.employee_name))
|
||||
raise Exception
|
||||
|
||||
def validate_curr_appraisal(self):
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if d.target_achieved or d.score:
|
||||
if self.doc.status == 'Draft':
|
||||
msgprint("Target achieved or Score can be added only for submitted Appraisal")
|
||||
raise Exception
|
||||
elif self.doc.status == 'Submitted' and session['user'] != self.doc.kra_approver:
|
||||
msgprint("Target achieved or Score can be added only by Appraisal Approver")
|
||||
raise Exception
|
||||
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
|
||||
ysd=fy and fy[0][0] or ""
|
||||
yed=add_days(str(ysd),365)
|
||||
if str(self.doc.start_date) < str(ysd) or str(self.doc.start_date) > str(yed) or str(self.doc.end_date) < str(ysd) or str(self.doc.end_date) > str(yed):
|
||||
msgprint("Appraisal date range is not within the Fiscal Year selected")
|
||||
raise Exception
|
||||
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.validate_existing_appraisal()
|
||||
self.validate_curr_appraisal()
|
||||
self.validate_fiscal_year()
|
||||
|
||||
def set_approver(self):
|
||||
ret={}
|
||||
approver_lst =[]
|
||||
emp_nm = self.get_employee_name()
|
||||
approver_lst1 = get_obj('Authorization Control').get_approver_name(self.doc.doctype,0,self)
|
||||
if approver_lst1:
|
||||
approver_lst=approver_lst1
|
||||
else:
|
||||
approver_lst = [x[0] for x in sql("select distinct name from `tabProfile` where enabled=1 and name!='Administrator' and name!='Guest' and docstatus!=2")]
|
||||
ret = {'app_lst':"\n" + "\n".join(approver_lst), 'emp_nm':cstr(emp_nm)}
|
||||
return ret
|
||||
|
||||
def calculate_total(self):
|
||||
total = 0
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if d.score:
|
||||
total = total + flt(d.score_earned)
|
||||
ret={'total_score':flt(total)}
|
||||
return ret
|
||||
|
||||
def declare_completed(self):
|
||||
ret={}
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if not d.target_achieved or not d.score or not d.score_earned:
|
||||
msgprint("Please add 'Target Achieved' and 'Score' for all KPI")
|
||||
ret = {'status':'Incomplete'}
|
||||
return ret
|
||||
|
||||
if not self.doc.total_score:
|
||||
msgprint("Please calculate total score using button 'Calculate Total Score'")
|
||||
ret = {'status':'No Score'}
|
||||
return ret
|
||||
self.update_appraisal()
|
||||
#set(self.doc, 'status', 'Completed')
|
||||
ret = {'status':'Completed'}
|
||||
return ret
|
||||
|
||||
def update_appraisal(self):
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
if not d.kra or not d.per_weightage:
|
||||
msgprint("Please remove the extra blank row added")
|
||||
raise Exception
|
||||
d.save()
|
||||
if self.doc.total_score:
|
||||
set(self.doc,'total_score',self.doc.total_score)
|
||||
|
||||
def on_update(self):
|
||||
set(self.doc, 'status', 'Draft')
|
||||
|
||||
def validate_total_weightage(self):
|
||||
total_w = 0
|
||||
for d in getlist(self.doclist, 'appraisal_details'):
|
||||
total_w = flt(total_w) + flt(d.per_weightage)
|
||||
|
||||
if flt(total_w)>100 or flt(total_w)<100:
|
||||
msgprint("Total of weightage assigned to KPI is "+cstr(total_w)+".It should be 100(%)")
|
||||
raise Exception
|
||||
|
||||
def validate_appraisal_detail(self):
|
||||
if not self.doc.kra_approver:
|
||||
msgprint("Please mention the name of Approver")
|
||||
raise Exception
|
||||
|
||||
if not getlist(self.doclist, 'appraisal_details'):
|
||||
msgprint("Please add KRA Details")
|
||||
raise Exception
|
||||
|
||||
self.validate_total_weightage()
|
||||
|
||||
def on_submit(self):
|
||||
self.validate_appraisal_detail()
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
set(self.doc, 'status', 'Cancelled')
|
||||
|
@ -5,16 +5,17 @@
|
||||
{
|
||||
'creation': '2010-09-01 15:48:05',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-27 14:39:10',
|
||||
'modified': '2011-09-22 10:59:43',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308808105',
|
||||
'_last_update': '1316075905',
|
||||
'autoname': 'APRSL.#####',
|
||||
'colour': 'White:FFF',
|
||||
'default_print_format': 'Standard',
|
||||
'doctype': 'DocType',
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
@ -22,7 +23,7 @@
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 160
|
||||
'version': 161
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -56,7 +57,6 @@
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'submit': 1,
|
||||
@ -66,7 +66,6 @@
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
@ -77,7 +76,6 @@
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'submit': 1,
|
||||
@ -87,7 +85,6 @@
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
@ -98,7 +95,6 @@
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 0,
|
||||
'role': 'HR Manager',
|
||||
'submit': 1,
|
||||
@ -111,7 +107,6 @@
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 0,
|
||||
'role': 'HR User',
|
||||
'submit': 1,
|
||||
@ -121,7 +116,6 @@
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 7,
|
||||
'permlevel': 1,
|
||||
'role': 'HR Manager'
|
||||
},
|
||||
@ -129,7 +123,6 @@
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 8,
|
||||
'permlevel': 1,
|
||||
'role': 'HR User'
|
||||
},
|
||||
@ -138,7 +131,6 @@
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Employee Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
@ -151,9 +143,9 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'status',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Status',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'status',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nDraft\nSubmitted\nCompleted\nCancelled',
|
||||
@ -168,7 +160,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee',
|
||||
'oldfieldname': 'employee',
|
||||
@ -185,7 +176,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'employee_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Employee Name',
|
||||
'oldfieldname': 'employee_name',
|
||||
@ -198,7 +188,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
@ -213,7 +202,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
@ -227,7 +215,6 @@
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 7,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
@ -238,7 +225,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Start Date',
|
||||
'oldfieldname': 'start_date',
|
||||
@ -252,7 +238,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'end_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'End Date',
|
||||
'oldfieldname': 'end_date',
|
||||
@ -267,7 +252,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra_approver',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 10,
|
||||
'in_filter': 0,
|
||||
'label': 'Approver',
|
||||
'oldfieldname': 'kra_approver',
|
||||
@ -282,7 +266,6 @@
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'idx': 11,
|
||||
'label': 'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amended_from',
|
||||
@ -299,7 +282,6 @@
|
||||
'fieldname': 'amendment_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 1,
|
||||
'idx': 12,
|
||||
'label': 'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amendment_date',
|
||||
@ -316,7 +298,6 @@
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 13,
|
||||
'label': 'Declare Completed',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
@ -327,7 +308,6 @@
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 14,
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
@ -340,7 +320,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra_template',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 15,
|
||||
'label': 'KRA Template',
|
||||
'oldfieldname': 'kra_template',
|
||||
'oldfieldtype': 'Link',
|
||||
@ -352,7 +331,6 @@
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 16,
|
||||
'label': 'Fetch Template',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'fetch_kra',
|
||||
@ -366,7 +344,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'hidden': 1,
|
||||
'idx': 17,
|
||||
'label': 'Update',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
@ -380,7 +357,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'appraisal_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 18,
|
||||
'label': 'Appraisal Details',
|
||||
'oldfieldname': 'appraisal_details',
|
||||
'oldfieldtype': 'Table',
|
||||
@ -393,7 +369,6 @@
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 19,
|
||||
'label': 'Calculate Total Score',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'calculate_total',
|
||||
@ -405,8 +380,7 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_score',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 20,
|
||||
'label': 'Total Score',
|
||||
'label': 'Total Score (Out of 5)',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'total_score',
|
||||
'oldfieldtype': 'Currency',
|
||||
|
@ -5,8 +5,8 @@
|
||||
{
|
||||
'creation': '2010-09-01 15:48:05',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'rahul@webnotestech.com',
|
||||
'modified': '2011-09-22 10:45:37',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
@ -14,13 +14,14 @@
|
||||
{
|
||||
'autoname': 'APRSLD.#####',
|
||||
'colour': 'White:FFF',
|
||||
'default_print_format': 'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'HR',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 13
|
||||
'version': 15
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -45,7 +46,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'kra',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'KRA',
|
||||
'oldfieldname': 'kra',
|
||||
'oldfieldtype': 'Small Text',
|
||||
@ -58,7 +58,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per_weightage',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 2,
|
||||
'label': 'Weightage (%)',
|
||||
'oldfieldname': 'per_weightage',
|
||||
'oldfieldtype': 'Currency',
|
||||
@ -72,7 +71,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'target_achieved',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 3,
|
||||
'label': 'Target Achieved',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'target_achieved',
|
||||
@ -86,15 +84,15 @@
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'score',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'fieldtype': 'Currency',
|
||||
'label': 'Score (0-5)',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'score',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\n0\n1\n2\n3\n4\n5',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
'trigger': 'Client',
|
||||
'width': '60px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
@ -102,7 +100,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'score_earned',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Score Earned',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'score_earned',
|
||||
|
Loading…
Reference in New Issue
Block a user