appraisal, don't validate points for self-appraisal

This commit is contained in:
Rushabh Mehta 2013-01-19 10:54:03 +05:30
parent f2223102e2
commit 3ab6c5fca9
4 changed files with 39 additions and 29 deletions

View File

@ -29,7 +29,15 @@ class DocType:
def __init__(self, doc, doclist=[]): def __init__(self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
def validate(self):
if not self.doc.status:
self.doc.status = "Draft"
self.validate_dates()
self.validate_existing_appraisal()
self.calculate_total()
def get_employee_name(self): def get_employee_name(self):
emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee) emp_nm = sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
emp_nm= emp_nm and emp_nm[0][0] or '' emp_nm= emp_nm and emp_nm[0][0] or ''
@ -47,25 +55,19 @@ class DocType:
raise Exception raise Exception
def validate_existing_appraisal(self): 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)) 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: if chk:
msgprint("You have already created Appraisal "\ msgprint("You have already created Appraisal "\
+cstr(chk[0][0])+" in the current date range for employee "\ +cstr(chk[0][0])+" in the current date range for employee "\
+cstr(self.doc.employee_name)) +cstr(self.doc.employee_name))
raise Exception raise Exception
def validate(self):
if not self.doc.status:
self.doc.status = "Draft"
self.validate_dates()
self.validate_existing_appraisal()
self.calculate_total()
def calculate_total(self): def calculate_total(self):
total, total_w = 0, 0 total, total_w = 0, 0
for d in getlist(self.doclist, 'appraisal_details'): for d in getlist(self.doclist, 'appraisal_details'):
if d.score: if d.score:
d.score_earned = flt(d.score) * flt(d.per_weightage) / 100 d.score_earned = flt(d.score) * flt(d.per_weightage) / 100
total = total + d.score_earned total = total + d.score_earned
@ -74,9 +76,12 @@ class DocType:
if int(total_w) != 100: if int(total_w) != 100:
msgprint("Total weightage assigned should be 100%. It is :" + str(total_w) + "%", msgprint("Total weightage assigned should be 100%. It is :" + str(total_w) + "%",
raise_exception=1) raise_exception=1)
if webnotes.conn.get_default("employee", webnotes.session.user) != self.doc.employee:
if total==0: if total==0:
msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1) msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1)
self.doc.total_score = total self.doc.total_score = total
def on_submit(self): def on_submit(self):

View File

@ -2,9 +2,9 @@
{ {
"owner": "jai@webnotestech.com", "owner": "jai@webnotestech.com",
"docstatus": 0, "docstatus": 0,
"creation": "2013-01-16 14:48:56", "creation": "2013-01-19 10:23:35",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2013-01-17 11:39:55" "modified": "2013-01-19 10:31:03"
}, },
{ {
"read_only": 1, "read_only": 1,
@ -31,8 +31,8 @@
"submit": 0, "submit": 0,
"doctype": "DocPerm", "doctype": "DocPerm",
"write": 1, "write": 1,
"report": 0,
"parenttype": "DocType", "parenttype": "DocType",
"report": 1,
"permlevel": 0, "permlevel": 0,
"parentfield": "permissions" "parentfield": "permissions"
}, },
@ -70,9 +70,9 @@
{ {
"doctype": "DocField", "doctype": "DocField",
"label": "Company", "label": "Company",
"reqd": 1,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"reqd": 1,
"options": "Company" "options": "Company"
}, },
{ {
@ -161,9 +161,9 @@
"default": "1", "default": "1",
"doctype": "DocField", "doctype": "DocField",
"label": "Use Multi-Level BOM", "label": "Use Multi-Level BOM",
"reqd": 0,
"fieldname": "use_multi_level_bom", "fieldname": "use_multi_level_bom",
"fieldtype": "Check" "fieldtype": "Check",
"reqd": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
@ -181,9 +181,9 @@
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"label": "Materials Requirement Planning (MRP)",
"fieldname": "sb5", "fieldname": "sb5",
"fieldtype": "Section Break", "fieldtype": "Section Break"
"options": "Simple"
}, },
{ {
"description": "Download a report containing all raw materials with their latest inventory status", "description": "Download a report containing all raw materials with their latest inventory status",
@ -213,6 +213,10 @@
"fieldtype": "Button", "fieldtype": "Button",
"options": "raise_purchase_request" "options": "raise_purchase_request"
}, },
{
"role": "System Manager",
"doctype": "DocPerm"
},
{ {
"role": "Manufacturing User", "role": "Manufacturing User",
"doctype": "DocPerm" "doctype": "DocPerm"

View File

@ -2,11 +2,12 @@ import webnotes
def execute(): def execute():
webnotes.reload_doc("core", "doctype", "patch_log") webnotes.reload_doc("core", "doctype", "patch_log")
for d in webnotes.conn.sql("""select patch from __PatchLog"""): if webnotes.conn.table_exists("__PatchLog"):
webnotes.doc({ for d in webnotes.conn.sql("""select patch from __PatchLog"""):
"doctype": "Patch Log", webnotes.doc({
"patch": d[0] "doctype": "Patch Log",
}).insert() "patch": d[0]
}).insert()
webnotes.conn.commit() webnotes.conn.commit()
webnotes.conn.sql("drop table __PatchLog") webnotes.conn.sql("drop table __PatchLog")

View File

@ -50,7 +50,7 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
lead.ignore_permissions = True lead.ignore_permissions = True
lead.insert() lead.insert()
make(content=message, sender=sender, make(content=message, sender=sender, subject=subject,
doctype="Lead", name=lead.doc.name, lead=lead.doc.name) doctype="Lead", name=lead.doc.name, lead=lead.doc.name)