leave application fix, print_table Sr fix
diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js
index 474ad13..8ba0978 100644
--- a/hr/doctype/expense_claim/expense_claim.js
+++ b/hr/doctype/expense_claim/expense_claim.js
@@ -56,10 +56,11 @@
if(user==doc.exp_approver) {
if(doc.approval_status=="Draft") {
cur_frm.set_intro("You are the Expense Approver for this record. Please Update the 'Status' and Save");
- cur_frm.set_df_property("approval_status", "permlevel", 0);
+ cur_frm.toggle_enable("approval_status", true);
}
} else {
cur_frm.set_intro("Expense Claim is pending approval. Only the Expense Approver can update status.");
+ cur_frm.toggle_enable("approval_status", false);
}
} else {
if(doc.approval_status=="Approved") {
diff --git a/hr/doctype/leave_application/leave_application.js b/hr/doctype/leave_application/leave_application.js
index 7398c36..2d71aac 100755
--- a/hr/doctype/leave_application/leave_application.js
+++ b/hr/doctype/leave_application/leave_application.js
@@ -35,9 +35,10 @@
if(doc.status=="Open") {
if(user==doc.leave_approver) {
cur_frm.set_intro("You are the Leave Approver for this record. Please Update the 'Status' and Save");
- cur_frm.set_df_property("status", "permlevel", 2);
+ cur_frm.toggle_enable("status", true);
} else {
cur_frm.set_intro("This Leave Application is pending approval. Only the Leave Apporver can update status.")
+ cur_frm.toggle_enable("status", false);
}
} else {
if(doc.status=="Approved") {
@@ -92,7 +93,7 @@
cur_frm.call({
method: "get_leave_balance",
args: {
- employee: doc.name,
+ employee: doc.employee,
fiscal_year: doc.fiscal_year,
leave_type: doc.leave_type
}
diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py
index bd76c7d..cdddb9f 100755
--- a/hr/doctype/leave_application/leave_application.py
+++ b/hr/doctype/leave_application/leave_application.py
@@ -63,7 +63,8 @@
def validate_balance_leaves(self):
if self.doc.from_date and self.doc.to_date and not self.is_lwp():
- bal = get_leave_balance(self.doc.leave_type, self.doc.employee, self.doc.fiscal_year)
+ bal = get_leave_balance(self.doc.leave_type, self.doc.employee,
+ self.doc.fiscal_year)["leave_balance"]
tot_leaves = self.get_total_leave_days()
bal, tot_leaves = bal, tot_leaves
webnotes.conn.set(self.doc,'leave_balance',flt(bal['leave_balance']))
@@ -106,17 +107,18 @@
@webnotes.whitelist()
def get_leave_balance(employee, leave_type, fiscal_year):
leave_all = webnotes.conn.sql("""select total_leaves_allocated
- from `tabLeave Allocation` where employee = '%s' and leave_type = '%s'
- and fiscal_year = '%s' and docstatus = 1""" % (employee,
+ from `tabLeave Allocation` where employee = %s and leave_type = %s
+ and fiscal_year = %s and docstatus = 1""", (employee,
leave_type, fiscal_year))
leave_all = leave_all and flt(leave_all[0][0]) or 0
+
leave_app = webnotes.conn.sql("""select SUM(total_leave_days)
from `tabLeave Application`
- where employee = '%s'
- and leave_type = '%s' and fiscal_year = '%s'
- and docstatus = 1""" % (employee, leave_type, fiscal_year))
+ where employee = %s and leave_type = %s and fiscal_year = %s
+ and docstatus = 1""", (employee, leave_type, fiscal_year))
leave_app = leave_app and flt(leave_app[0][0]) or 0
+
ret = {'leave_balance':leave_all - leave_app}
return ret
diff --git a/hr/doctype/leave_application/leave_application.txt b/hr/doctype/leave_application/leave_application.txt
index 35a16a9..b205d18 100644
--- a/hr/doctype/leave_application/leave_application.txt
+++ b/hr/doctype/leave_application/leave_application.txt
@@ -2,9 +2,9 @@
{
"owner": "Administrator",
"docstatus": 0,
- "creation": "2012-12-03 10:13:48",
+ "creation": "2012-12-05 14:11:53",
"modified_by": "Administrator",
- "modified": "2012-12-05 11:59:15"
+ "modified": "2012-12-05 17:38:26"
},
{
"is_submittable": 1,
@@ -255,11 +255,5 @@
"doctype": "DocPerm",
"role": "All",
"permlevel": 3
- },
- {
- "doctype": "DocPerm",
- "write": 1,
- "role": "HR User",
- "permlevel": 3
}
]
\ No newline at end of file