workflow patch fix
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ed051b0..846ca26 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -489,4 +489,4 @@
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
erpnext.patches.v10_0.update_assessment_plan
erpnext.patches.v10_0.update_assessment_result
-erpnext.patches.v10_0.workflow_leave_application
\ No newline at end of file
+erpnext.patches.v10_0.workflow_leave_application #2018-01-24
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/workflow_leave_application.py b/erpnext/patches/v10_0/workflow_leave_application.py
index 5db5dd9..f2b74a3 100644
--- a/erpnext/patches/v10_0/workflow_leave_application.py
+++ b/erpnext/patches/v10_0/workflow_leave_application.py
@@ -3,49 +3,10 @@
from __future__ import unicode_literals
import frappe
+from erpnext.setup.install import leave_application_workflow
def execute():
frappe.reload_doc("hr", "doctype", "leave_application")
frappe.reload_doc("workflow", "doctype", "workflow")
-
- if not frappe.db.exists("Workflow State", "Open"):
- frappe.get_doc({
- 'doctype': 'Workflow State',
- 'workflow_state_name': 'Open',
- 'style': 'Warning'
- }).insert(ignore_permissions=True)
-
- 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)
-
+ leave_application_workflow()
frappe.db.sql("""update `tabLeave Application` set workflow_state = status""")
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index 81f909a..1c64610 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -12,6 +12,7 @@
<a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
def after_install():
+ leave_application_workflow()
frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
set_single_defaults()
create_compact_item_print_custom_field()
@@ -19,6 +20,51 @@
add_all_roles_to("Administrator")
frappe.db.commit()
+def leave_application_workflow():
+ states = {'Approved': 'Success', 'Rejected': 'Danger', 'Open': 'Warning'}
+
+ for state, style in states.items():
+ if not frappe.db.exists("Workflow State", state):
+ frappe.get_doc({
+ 'doctype': 'Workflow State',
+ 'workflow_state_name': state,
+ 'style': style
+ }).insert(ignore_permissions=True)
+
+ if not frappe.db.exists("Workflow", "Leave Approval"):
+ 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)
+
def check_setup_wizard_not_completed():
if frappe.db.get_default('desktop:home_page') == 'desktop':
print()
diff --git a/erpnext/startup/notifications.py b/erpnext/startup/notifications.py
index eb06f27..b8fce6e 100644
--- a/erpnext/startup/notifications.py
+++ b/erpnext/startup/notifications.py
@@ -30,7 +30,7 @@
"docstatus": ("<", 2)
},
"Payment Entry": {"docstatus": 0},
- "Leave Application": {"status": "Open"},
+ "Leave Application": {"docstatus": 0},
"Expense Claim": {"approval_status": "Draft"},
"Job Applicant": {"status": "Open"},
"Delivery Note": {