Merge pull request #23781 from rohitwaghchaure/patch-to-update-reason-for-leaving
fix: patch to update reason for leaving in employee
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 8b34eaa..5ef5371 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -732,3 +732,4 @@
erpnext.patches.v13_0.print_uom_after_quantity_patch
erpnext.patches.v13_0.set_payment_channel_in_payment_gateway_account
erpnext.patches.v13_0.create_healthcare_custom_fields_in_stock_entry_detail
+erpnext.patches.v13_0.update_reason_for_resignation_in_employee
diff --git a/erpnext/patches/v13_0/update_reason_for_resignation_in_employee.py b/erpnext/patches/v13_0/update_reason_for_resignation_in_employee.py
new file mode 100644
index 0000000..792118f
--- /dev/null
+++ b/erpnext/patches/v13_0/update_reason_for_resignation_in_employee.py
@@ -0,0 +1,15 @@
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
+# MIT License. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doc("hr", "doctype", "employee")
+
+ if frappe.db.has_column("Employee", "reason_for_resignation"):
+ frappe.db.sql(""" UPDATE `tabEmployee`
+ SET reason_for_leaving = reason_for_resignation
+ WHERE status = 'Left' and reason_for_leaving is null and reason_for_resignation is not null
+ """)
+