[patch] Set 'Credit days based on' in existing customer, customer group and company
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index b21d31b..f3282f7 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -171,3 +171,4 @@
 erpnext.patches.v5_0.item_variants
 erpnext.patches.v5_0.update_item_desc_in_invoice
 erpnext.patches.v5_1.fix_against_account
+erpnext.patches.v5_1.fix_credit_days_based_on
\ No newline at end of file
diff --git a/erpnext/patches/v5_1/fix_credit_days_based_on.py b/erpnext/patches/v5_1/fix_credit_days_based_on.py
new file mode 100644
index 0000000..9277818
--- /dev/null
+++ b/erpnext/patches/v5_1/fix_credit_days_based_on.py
@@ -0,0 +1,8 @@
+from __future__ import unicode_literals
+
+import frappe
+
+def execute():
+	for dt in ("Customer", "Customer Group", "Company"):
+		frappe.db.sql("""update `tab{0}` set credit_days_based_on='Fixed Days'
+			where ifnull(credit_days, 0) > 0""".format(dt))
\ No newline at end of file