Remove hardcoded workflow patches (#14340)

This commit is contained in:
Shreya Shah 2018-06-05 10:35:07 +05:30 committed by Rushabh Mehta
parent b75e77a2cc
commit f1e54836cb
3 changed files with 0 additions and 147 deletions

View File

@ -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

View File

@ -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""")

View File

@ -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""")