From f1e54836cb766d2a3b85667372b4a74e9e842096 Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Tue, 5 Jun 2018 10:35:07 +0530 Subject: [PATCH] Remove hardcoded workflow patches (#14340) --- erpnext/patches.txt | 2 - .../patches/v10_0/workflow_expense_claim.py | 71 ------------------ .../v10_0/workflow_leave_application.py | 74 ------------------- 3 files changed, 147 deletions(-) delete mode 100644 erpnext/patches/v10_0/workflow_expense_claim.py delete mode 100644 erpnext/patches/v10_0/workflow_leave_application.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 79bbf359aa..c80eef22bb 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -490,14 +490,12 @@ 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.added_extra_gst_custom_field -erpnext.patches.v10_0.workflow_leave_application #2018-01-24 #2018-02-02 #2018-02-08 erpnext.patches.v10_0.set_default_payment_terms_based_on_company erpnext.patches.v10_0.update_sales_order_link_to_purchase_order erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2 #2018-02-13 erpnext.patches.v10_0.item_barcode_childtable_migrate erpnext.patches.v10_0.rename_price_to_rate_in_pricing_rule erpnext.patches.v10_0.set_currency_in_pricing_rule -erpnext.patches.v10_0.workflow_expense_claim erpnext.patches.v10_0.set_b2c_limit erpnext.patches.v10_0.update_translatable_fields erpnext.patches.v10_0.rename_offer_letter_to_job_offer diff --git a/erpnext/patches/v10_0/workflow_expense_claim.py b/erpnext/patches/v10_0/workflow_expense_claim.py deleted file mode 100644 index 2e99fbf8eb..0000000000 --- a/erpnext/patches/v10_0/workflow_expense_claim.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (c) 2017, Frappe and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - if frappe.db.a_row_exists("Expense Claim"): - frappe.reload_doc("hr", "doctype", "expense_claim") - frappe.reload_doc("hr", "doctype", "vehicle_log") - frappe.reload_doc("hr", "doctype", "expense_claim_advance") - frappe.reload_doc("workflow", "doctype", "workflow") - - states = {'Approved': 'Success', 'Rejected': 'Danger', 'Draft': '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) - - for action in ['Approve', 'Reject']: - if not frappe.db.exists("Workflow Action", action): - frappe.get_doc({ - 'doctype': 'Workflow Action', - 'workflow_action_name': action - }).insert(ignore_permissions=True) - - if not frappe.db.exists("Workflow", "Expense Approval"): - frappe.get_doc({ - 'doctype': 'Workflow', - 'workflow_name': 'Expense Approval', - 'document_type': 'Expense Claim', - 'is_active': 1, - 'workflow_state_field': 'workflow_state', - 'states': [{ - "state": 'Draft', - "doc_status": 0, - "update_field": "approval_status", - "update_value": "Draft", - "allow_edit": 'Employee' - }, { - "state": 'Approved', - "doc_status": 1, - "update_field": "approval_status", - "update_value": "Approved", - "allow_edit": 'Expense Approver' - }, { - "state": 'Rejected', - "doc_status": 0, - "update_field": "approval_status", - "update_value": "Rejected", - "allow_edit": 'Expense Approver' - }], - 'transitions': [{ - "state": 'Draft', - "action": 'Approve', - "next_state": 'Approved', - "allowed": 'Expense Approver' - }, - { - "state": 'Draft', - "action": 'Reject', - "next_state": 'Rejected', - "allowed": 'Expense Approver' - }] - }).insert(ignore_permissions=True) - - if frappe.db.has_column("Expense Claim", "status"): - frappe.db.sql("""update `tabExpense Claim` set workflow_state = approval_status""") diff --git a/erpnext/patches/v10_0/workflow_leave_application.py b/erpnext/patches/v10_0/workflow_leave_application.py deleted file mode 100644 index 637c07602a..0000000000 --- a/erpnext/patches/v10_0/workflow_leave_application.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (c) 2017, Frappe and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe - -def execute(): - if frappe.db.a_row_exists("Leave Application"): - frappe.reload_doc("hr", "doctype", "leave_application") - frappe.reload_doc("workflow", "doctype", "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) - - for action in ["Approve", "Reject"]: - if not frappe.db.exists("Workflow Action", action): - frappe.get_doc({ - "doctype": "Workflow Action", - "workflow_action_name": action - }).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, - "update_field": "status", - "update_value": "Open", - "allow_edit": "Employee" - }, { - "state": "Approved", - "doc_status": 1, - "update_field": "status", - "update_value": "Approved", - "allow_edit": "Leave Approver" - }, { - "state": "Rejected", - "doc_status": 0, - "update_field": "status", - "update_value": "Rejected", - "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) - - if frappe.db.has_column("Leave Application", "status"): - frappe.db.sql("""update `tabLeave Application` set workflow_state = status""") - - if frappe.db.has_column("Leave Application", "workflow_state"): - frappe.db.sql("""update `tabWorkflow Document State` set doc_status = 0 where parent = "Leave Approval" \ - and state = "Rejected" and doc_status = 1""") - frappe.db.sql("""update `tabLeave Application` set docstatus = 0 where workflow_state = "Rejected" and docstatus = 1""")