Merge pull request #32091 from nabinhait/lead-notes-patch
fix: Migrate old lead notes as per the new format
This commit is contained in:
commit
f8bee0e75f
@ -307,6 +307,7 @@ erpnext.patches.v13_0.job_card_status_on_hold
|
|||||||
erpnext.patches.v14_0.copy_is_subcontracted_value_to_is_old_subcontracting_flow
|
erpnext.patches.v14_0.copy_is_subcontracted_value_to_is_old_subcontracting_flow
|
||||||
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
||||||
erpnext.patches.v14_0.crm_ux_cleanup
|
erpnext.patches.v14_0.crm_ux_cleanup
|
||||||
|
erpnext.patches.v14_0.migrate_existing_lead_notes_as_per_the_new_format
|
||||||
erpnext.patches.v14_0.remove_india_localisation # 14-07-2022
|
erpnext.patches.v14_0.remove_india_localisation # 14-07-2022
|
||||||
erpnext.patches.v13_0.fix_number_and_frequency_for_monthly_depreciation
|
erpnext.patches.v13_0.fix_number_and_frequency_for_monthly_depreciation
|
||||||
erpnext.patches.v14_0.remove_hr_and_payroll_modules # 20-07-2022
|
erpnext.patches.v14_0.remove_hr_and_payroll_modules # 20-07-2022
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.utils import cstr, strip_html
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for doctype in ("Lead", "Prospect", "Opportunity"):
|
||||||
|
if not frappe.db.has_column(doctype, "notes"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
dt = frappe.qb.DocType(doctype)
|
||||||
|
records = (
|
||||||
|
frappe.qb.from_(dt)
|
||||||
|
.select(dt.name, dt.notes, dt.modified_by, dt.modified)
|
||||||
|
.where(dt.notes.isnotnull() & dt.notes != "")
|
||||||
|
).run()
|
||||||
|
|
||||||
|
for d in records:
|
||||||
|
if strip_html(cstr(d.notes)).strip():
|
||||||
|
doc = frappe.get_doc(doctype, d.name)
|
||||||
|
doc.append("notes", {"note": d.notes, "added_by": d.modified_by, "added_on": d.modified})
|
||||||
|
doc.update_child_table("notes")
|
||||||
|
|
||||||
|
frappe.db.sql_ddl(f"alter table `tab{doctype}` drop column `notes`")
|
Loading…
x
Reference in New Issue
Block a user