Add patch to set update_field and update_value (#14421)

* Add patch to set update_field and update_value

- set update_field and update_value if empty
since expense claim workflow is dependent on it.

* Set update_field for workflow state of leave application

* Update patch entry

* Fix bug

* Update set_update_field_and_value_in_workflow_state.py
This commit is contained in:
Suraj Shetty 2018-06-08 16:28:36 +05:30 committed by Nabin Hait
parent ca8138fd13
commit f553b53fbf
2 changed files with 19 additions and 0 deletions

View File

@ -546,3 +546,4 @@ erpnext.patches.v11_0.update_backflush_subcontract_rm_based_on_bom
erpnext.patches.v10_0.update_status_in_purchase_receipt
erpnext.patches.v11_0.inter_state_field_for_gst
erpnext.patches.v11_0.rename_members_with_naming_series #04-06-2018
erpnext.patches.v11_0.set_update_field_and_value_in_workflow_state

View File

@ -0,0 +1,18 @@
import frappe
from frappe.model.workflow import get_workflow_name
def execute():
for doctype in ['Expense Claim', 'Leave Application']:
active_workflow = get_workflow_name(doctype)
if not active_workflow: continue
workflow_states = frappe.get_all('Workflow Document State',
filters=[['parent', '=', active_workflow]],
fields=['*'])
for state in workflow_states:
if state.update_field: continue
status_field = 'approval_status' if doctype=="Expense Claim" else 'status'
frappe.set_value('Workflow Document State', state.name, 'update_field', status_field)
frappe.set_value('Workflow Document State', state.name, 'update_value', state.state)