From 980defb36886df68849f5ae4264fe5fca40ab3ec Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 16 Mar 2024 19:25:28 +0530 Subject: [PATCH] patch: move data from crm note to fcrm note --- crm/patches.txt | 2 +- ...ote.py => move_crm_note_data_to_fcrm_note.py} | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) rename crm/patches/v1_0/{rename_crm_note_to_fcrm_note.py => move_crm_note_data_to_fcrm_note.py} (63%) diff --git a/crm/patches.txt b/crm/patches.txt index dd4f4b11..a16089c3 100644 --- a/crm/patches.txt +++ b/crm/patches.txt @@ -1,7 +1,7 @@ [pre_model_sync] # Patches added in this section will be executed before doctypes are migrated # Read docs to understand patches: https://frappeframework.com/docs/v14/user/en/database-migrations -crm.patches.v1_0.rename_crm_note_to_fcrm_note #also move data from crm_note to fcrm_note +crm.patches.v1_0.move_crm_note_data_to_fcrm_note [post_model_sync] # Patches added in this section will be executed after doctypes are migrated diff --git a/crm/patches/v1_0/rename_crm_note_to_fcrm_note.py b/crm/patches/v1_0/move_crm_note_data_to_fcrm_note.py similarity index 63% rename from crm/patches/v1_0/rename_crm_note_to_fcrm_note.py rename to crm/patches/v1_0/move_crm_note_data_to_fcrm_note.py index 5f20ee85..2f1b319e 100644 --- a/crm/patches/v1_0/rename_crm_note_to_fcrm_note.py +++ b/crm/patches/v1_0/move_crm_note_data_to_fcrm_note.py @@ -3,15 +3,17 @@ from frappe.model.rename_doc import rename_doc def execute(): - if frappe.db.exists("DocType", "FCRM Note"): + + if not frappe.db.exists("DocType", "FCRM Note"): + frappe.flags.ignore_route_conflict_validation = True + rename_doc("DocType", "CRM Note", "FCRM Note") + frappe.flags.ignore_route_conflict_validation = False + + frappe.reload_doctype("FCRM Note", force=True) + + if frappe.db.exists("DocType", "FCRM Note") and frappe.db.count("FCRM Note") > 0: return - frappe.flags.ignore_route_conflict_validation = True - rename_doc("DocType", "CRM Note", "FCRM Note") - frappe.flags.ignore_route_conflict_validation = False - - frappe.reload_doctype("FCRM Note", force=True) - notes = frappe.db.sql("SELECT * FROM `tabCRM Note`", as_dict=True) if notes: for note in notes: