diff --git a/erpnext/patches/v10_0/workflow_leave_application.py b/erpnext/patches/v10_0/workflow_leave_application.py new file mode 100644 index 0000000000..ca31128c21 --- /dev/null +++ b/erpnext/patches/v10_0/workflow_leave_application.py @@ -0,0 +1,51 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("hr", "doctype", "leave_application") + frappe.reload_doc("workflow", "doctype", "workflow") + + doc = frappe.get_doc({ + 'doctype': 'Workflow State', + 'workflow_state_name': 'Open', + 'style': 'Warning' + }).insert(ignore_permissions=True) + + doc = frappe.get_doc({ + 'doctype': 'Workflow', + 'workflow_name': 'Leave Approval', + 'document_type': 'Leave Application', + 'is_active': 1, + 'workflow_state_field': 'workflow_state', + 'states': [{ + "state": 'Open', + "doc_status": 0, + "allow_edit": 'Employee' + }, { + "state": 'Approved', + "doc_status": 1, + "allow_edit": 'Leave Approver' + }, { + "state": 'Rejected', + "doc_status": 1, + "allow_edit": 'Leave Approver' + }], + 'transitions': [{ + "state": 'Open', + "action": 'Approve', + "next_state": 'Approved', + "allowed": 'Leave Approver' + }, + { + "state": 'Open', + "action": 'Reject', + "next_state": 'Rejected', + "allowed": 'Leave Approver' + }] + }).insert(ignore_permissions=True) + + frappe.db.sql("""update `tabLeave Application` set workflow_state = status""") + frappe.db.sql("""alter table `tabLeave Application` drop column status""")