diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py index 504478a2413..e59c3eeffe8 100644 --- a/erpnext/demo/user/hr.py +++ b/erpnext/demo/user/hr.py @@ -192,7 +192,7 @@ def mark_attendance(): "attendance_date": attendance_date }) leave = frappe.db.sql("""select name from `tabLeave Application` - where employee = %s and %s between from_date and to_date and status = 'Approved' + where employee = %s and %s between from_date and to_date and workflow_state = 'Approved' and docstatus = 1""", (employee.name, attendance_date)) if leave: diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py index 458b2dd5c19..fd7344a4958 100644 --- a/erpnext/hr/doctype/attendance/attendance.py +++ b/erpnext/hr/doctype/attendance/attendance.py @@ -21,7 +21,7 @@ class Attendance(Document): def check_leave_record(self): leave_record = frappe.db.sql("""select leave_type, half_day from `tabLeave Application` - where employee = %s and %s between from_date and to_date and status = 'Approved' + where employee = %s and %s between from_date and to_date and workflow_state = 'Approved' and docstatus = 1""", (self.employee, self.attendance_date), as_dict=True) if leave_record: if leave_record[0].half_day: diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js index 2eb155dee11..a4e0d8d36fe 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.js +++ b/erpnext/hr/doctype/leave_application/leave_application.js @@ -29,7 +29,6 @@ frappe.ui.form.on("Leave Application", { refresh: function(frm) { if (frm.is_new()) { - frm.set_value("status", "Open"); frm.trigger("calculate_total_days"); } }, diff --git a/erpnext/hr/doctype/leave_application/leave_application.json b/erpnext/hr/doctype/leave_application/leave_application.json index 7afbc4da898..f70b1df733a 100644 --- a/erpnext/hr/doctype/leave_application/leave_application.json +++ b/erpnext/hr/doctype/leave_application/leave_application.json @@ -59,7 +59,7 @@ "in_filter": 0, "in_global_search": 0, "in_list_view": 0, - "in_standard_filter": 1, + "in_standard_filter": 0, "label": "Status", "length": 0, "no_copy": 1, @@ -796,7 +796,7 @@ "issingle": 0, "istable": 0, "max_attachments": 3, - "modified": "2017-06-13 14:28:52.426044", + "modified": "2018-01-16 00:21:59.025871", "modified_by": "Administrator", "module": "HR", "name": "Leave Application", diff --git a/erpnext/hr/doctype/leave_application/leave_application_calendar.js b/erpnext/hr/doctype/leave_application/leave_application_calendar.js index d55c23b82bc..b06b40f38e3 100644 --- a/erpnext/hr/doctype/leave_application/leave_application_calendar.js +++ b/erpnext/hr/doctype/leave_application/leave_application_calendar.js @@ -7,7 +7,7 @@ frappe.views.calendar["Leave Application"] = { "end": "to_date", "id": "name", "title": "title", - "status": "status", + "workflow_state": "workflow_state", }, options: { header: { diff --git a/erpnext/hr/doctype/leave_application/leave_application_list.js b/erpnext/hr/doctype/leave_application/leave_application_list.js index 966d1aa2b6f..fba7297329f 100644 --- a/erpnext/hr/doctype/leave_application/leave_application_list.js +++ b/erpnext/hr/doctype/leave_application/leave_application_list.js @@ -1,8 +1,8 @@ frappe.listview_settings['Leave Application'] = { - add_fields: ["status", "leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"], - filters:[["status","!=", "Rejected"]], + add_fields: ["workflow_state", "leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"], + filters:[["workflow_state","!=", "Rejected"]], get_indicator: function(doc) { - return [__(doc.status), frappe.utils.guess_colour(doc.status), - "status,=," + doc.status]; + return [__(doc.workflow_state), frappe.utils.guess_colour(doc.workflow_state), + "workflow_state,=," + doc.workflow_state]; } }; diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.js b/erpnext/hr/doctype/leave_application/test_leave_application.js index 6028405c46e..7d5fdf0ef69 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.js +++ b/erpnext/hr/doctype/leave_application/test_leave_application.js @@ -21,28 +21,21 @@ QUnit.test("Test: Leave application [HR]", function (assert) { ]); }, () => frappe.timeout(1), - // check calculated total leave days - () => assert.ok(!cur_frm.doc.docstatus, - "leave application not submitted with status as open"), - () => cur_frm.set_value("status", "Approved"), // approve the application [as administrator] + + () => frappe.click_button('Actions'), () => frappe.timeout(0.5), - // save form - () => cur_frm.save(), - () => frappe.timeout(1), - () => cur_frm.savesubmit(), - () => frappe.timeout(1), - () => frappe.click_button('Yes'), - () => frappe.timeout(1), + () => frappe.click_button('Approve'), // approve the application [as administrator] () => assert.ok(cur_frm.doc.docstatus, "leave application submitted after approval"), // check auto filled posting date [today] + () => assert.equal(today_date, cur_frm.doc.posting_date, "posting date correctly set"), () => frappe.set_route("List", "Leave Application", "List"), () => frappe.timeout(1), - // check approved application in list - () => assert.deepEqual(["Test Employee 1", "Approved"], [cur_list.data[0].employee_name, cur_list.data[0].status], - "leave for correct employee is approved"), + // // check approved application in list + () => assert.deepEqual(["Test Employee 1", "Approved"], [cur_list.data[0].employee_name, cur_list.data[0].workflow_state], + // "leave for correct employee is approved"), () => done() ]); }); \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 0ec3efb7deb..b2f6054057b 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -103,7 +103,7 @@ class TestLeaveApplication(unittest.TestCase): application = self.get_application(_test_records[0]) application.insert() - application.status = "Approved" + application.workflow_state = "Approved" self.assertRaises(LeaveDayBlockedError, application.submit) frappe.set_user("test1@example.com") @@ -257,7 +257,7 @@ class TestLeaveApplication(unittest.TestCase): application.insert() frappe.set_user("test@example.com") - application.status = "Approved" + application.workflow_state = "Approved" # clear permlevel access cache on change user del application._has_access_to @@ -297,7 +297,7 @@ class TestLeaveApplication(unittest.TestCase): # submit leave application by Leave Approver frappe.set_user("test1@example.com") - application.status = "Approved" + application.workflow_state = "Approved" del application._has_access_to application.submit() self.assertEqual(frappe.db.get_value("Leave Application", application.name, @@ -339,7 +339,7 @@ class TestLeaveApplication(unittest.TestCase): application.insert() frappe.set_user("test1@example.com") del application._has_access_to - application.status = "Approved" + application.workflow_state = "Approved" from erpnext.hr.doctype.leave_application.leave_application import LeaveApproverIdentityError self.assertRaises(LeaveApproverIdentityError, application.submit) @@ -364,7 +364,7 @@ class TestLeaveApplication(unittest.TestCase): # change to valid leave approver and try to submit leave application frappe.set_user("test2@example.com") - application.status = "Approved" + application.workflow_state = "Approved" del application._has_access_to application.submit() self.assertEqual(frappe.db.get_value("Leave Application", application.name, diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index a4745696032..878c6b433ae 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -300,7 +300,7 @@ class SalarySlip(TransactionBase): where t2.name = t1.leave_type and t2.is_lwp = 1 and t1.docstatus = 1 - and t1.status = 'Approved' + and t1.workflow_state = 'Approved' and t1.employee = %(employee)s and CASE WHEN t2.include_holiday != 1 THEN %(dt)s not in ('{0}') and %(dt)s between from_date and to_date WHEN t2.include_holiday THEN %(dt)s between from_date and to_date