From d2b4ec50442a00df85ef525cc82aca971b72eb86 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 21 May 2018 13:37:39 +0530 Subject: [PATCH] [fix] Set null values to '0' before changing column type --- erpnext/patches/v11_0/rename_field_max_days_allowed.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v11_0/rename_field_max_days_allowed.py b/erpnext/patches/v11_0/rename_field_max_days_allowed.py index e0acf06f4b..dea43030de 100644 --- a/erpnext/patches/v11_0/rename_field_max_days_allowed.py +++ b/erpnext/patches/v11_0/rename_field_max_days_allowed.py @@ -1,7 +1,10 @@ import frappe -from frappe.model.utils.rename_field import rename_field def execute(): - frappe.reload_doc("hr", "doctype", "leave_type") + frappe.db.sql(""" + UPDATE `tabLeave Type` + SET max_days_allowed = '0' + WHERE trim(coalesce(max_days_allowed, '')) = '' + """) frappe.db.sql_ddl("""ALTER table `tabLeave Type` modify max_days_allowed int(8) NOT NULL""") - rename_field("Leave Type", "max_days_allowed", "max_continuous_days_allowed") +