diff --git a/erpnext/patches/v5_0/rename_table_fieldnames.py b/erpnext/patches/v5_0/rename_table_fieldnames.py index 2376eabd7b..758280fbaf 100644 --- a/erpnext/patches/v5_0/rename_table_fieldnames.py +++ b/erpnext/patches/v5_0/rename_table_fieldnames.py @@ -227,13 +227,16 @@ def execute(): frappe.reload_doc("accounts", "doctype", "fiscal_year_company") #rename table fieldnames - if frappe.db.exists("DocType", dn): - for dn in rename_map: - frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) + for dn in rename_map: + if not frappe.db.exists("DocType", dn): + continue + frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn)) - for dt, field_list in rename_map.items(): - for field in field_list: - rename_field(dt, field[0], field[1]) + for dt, field_list in rename_map.items(): + if not frappe.db.exists("DocType", dt): + continue + for field in field_list: + rename_field(dt, field[0], field[1]) # update voucher type for old, new in [["Bank Voucher", "Bank Entry"], ["Cash Voucher", "Cash Entry"],