From bf24581eb2fc1546efb8c397c9cafa7ec7b4791f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 5 Dec 2012 18:02:13 +0530 Subject: [PATCH] leave application fix, print_table Sr fix --- hr/doctype/expense_claim/expense_claim.js | 3 ++- hr/doctype/leave_application/leave_application.js | 5 +++-- hr/doctype/leave_application/leave_application.py | 14 ++++++++------ hr/doctype/leave_application/leave_application.txt | 10 ++-------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js index 474ad134cd..8ba097821f 100644 --- a/hr/doctype/expense_claim/expense_claim.js +++ b/hr/doctype/expense_claim/expense_claim.js @@ -56,10 +56,11 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){ 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 7398c36aff..2d71aac0e7 100755 --- a/hr/doctype/leave_application/leave_application.js +++ b/hr/doctype/leave_application/leave_application.js @@ -35,9 +35,10 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { 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 @@ get_leave_balance = function(doc, dt, dn) { 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 bd76c7df45..cdddb9f4d3 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -63,7 +63,8 @@ class DocType: 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 @@ class DocType: @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 35a16a9b98..b205d1832d 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