check if workflow_state_name already exists
diff --git a/erpnext/patches/v10_0/workflow_leave_application.py b/erpnext/patches/v10_0/workflow_leave_application.py
index 4e0d7e4..5db5dd9 100644
--- a/erpnext/patches/v10_0/workflow_leave_application.py
+++ b/erpnext/patches/v10_0/workflow_leave_application.py
@@ -8,11 +8,12 @@
frappe.reload_doc("hr", "doctype", "leave_application")
frappe.reload_doc("workflow", "doctype", "workflow")
- frappe.get_doc({
- 'doctype': 'Workflow State',
- 'workflow_state_name': 'Open',
- 'style': 'Warning'
- }).insert(ignore_permissions=True)
+ 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',