1
0
forked from test/crm

patch: move data from crm note to fcrm note

This commit is contained in:
Shariq Ansari 2024-03-16 19:25:28 +05:30
parent e3ff8657ef
commit 980defb368
2 changed files with 10 additions and 8 deletions

View File

@ -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

View File

@ -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: