From e3ff8657efba764c1a014e73b2339c6e7f0d98c6 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 16 Mar 2024 18:28:41 +0530 Subject: [PATCH] patch: move data from crm note to fcrm note --- crm/patches.txt | 2 +- .../v1_0/rename_crm_note_to_fcrm_note.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/crm/patches.txt b/crm/patches.txt index cbc0eaef..dd4f4b11 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 +crm.patches.v1_0.rename_crm_note_to_fcrm_note #also move data from crm_note 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/rename_crm_note_to_fcrm_note.py index 38cc09c3..5f20ee85 100644 --- a/crm/patches/v1_0/rename_crm_note_to_fcrm_note.py +++ b/crm/patches/v1_0/rename_crm_note_to_fcrm_note.py @@ -10,4 +10,20 @@ def execute(): rename_doc("DocType", "CRM Note", "FCRM Note") frappe.flags.ignore_route_conflict_validation = False - frappe.reload_doctype("FCRM Note", force=True) \ No newline at end of file + frappe.reload_doctype("FCRM Note", force=True) + + notes = frappe.db.sql("SELECT * FROM `tabCRM Note`", as_dict=True) + if notes: + for note in notes: + doc = frappe.get_doc({ + "doctype": "FCRM Note", + "creation": note.get("creation"), + "modified": note.get("modified"), + "modified_by": note.get("modified_by"), + "owner": note.get("owner"), + "title": note.get("title"), + "content": note.get("content"), + "reference_doctype": note.get("reference_doctype"), + "reference_docname": note.get("reference_docname"), + }) + doc.db_insert() \ No newline at end of file