[fix] set no_copy property for workflow state field (#5531)

* [fix] set no_copy property for workflow state field

* [fix] check if custom field exists before loading doc
This commit is contained in:
Saurabh 2018-05-08 15:16:08 +05:30 committed by Nabin Hait
parent 09e71d0d77
commit 2147bca5d4
3 changed files with 14 additions and 1 deletions

View file

@ -201,4 +201,5 @@ frappe.patches.v9_1.revert_domain_settings
frappe.patches.v9_1.move_feed_to_activity_log
execute:frappe.delete_doc('Page', 'data-import-tool', ignore_missing=True)
frappe.patches.v10_0.reload_countries_and_currencies
frappe.patches.v10_0.increase_single_table_column_length
frappe.patches.v10_0.set_no_copy_to_workflow_state
frappe.patches.v10_0.increase_single_table_column_length

View file

@ -0,0 +1,11 @@
import frappe
def execute():
for dt in frappe.get_all("Workflow", fields=['name', 'document_type', 'workflow_state_field']):
fieldname = frappe.db.get_value("Custom Field", filters={'dt': dt.document_type,
'fieldname': dt.workflow_state_field})
if fieldname:
custom_field = frappe.get_doc("Custom Field", fieldname)
custom_field.no_copy = 1
custom_field.save()

View file

@ -31,6 +31,7 @@ class Workflow(Document):
"label": self.workflow_state_field.replace("_", " ").title(),
"hidden": 1,
"allow_on_submit": 1,
"no_copy": 1,
"fieldtype": "Link",
"options": "Workflow State",
}).save()