From 61cf49dd0773112f0801b189e9c668be8f140028 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 24 Jan 2018 18:21:18 +0530 Subject: [PATCH] workflow patch fix --- erpnext/patches.txt | 2 +- .../v10_0/workflow_leave_application.py | 43 +---------------- erpnext/setup/install.py | 46 +++++++++++++++++++ erpnext/startup/notifications.py | 2 +- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index ed051b02b0..846ca269b1 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -489,4 +489,4 @@ erpnext.patches.v10_0.update_reserved_qty_for_purchase_order 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 5db5dd9309..f2b74a35a7 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 81f909aa84..1c646101b2 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -12,6 +12,7 @@ default_mail_footer = """
ERPNext
""" 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 @@ def after_install(): 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 eb06f27c70..b8fce6e6c1 100644 --- a/erpnext/startup/notifications.py +++ b/erpnext/startup/notifications.py @@ -30,7 +30,7 @@ def get_notification_config(): "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": {