fix: patch to delete the crm_deal custom fields

(cherry picked from commit 9613d72d81)
This commit is contained in:
diptanilsaha
2026-08-13 22:51:24 +05:30
committed by Mergify
parent 795cf8544c
commit d66dc143e3
2 changed files with 28 additions and 0 deletions

View File

@@ -500,3 +500,4 @@ erpnext.patches.v16_0.rename_italy_customer_name_fields
erpnext.patches.v16_0.set_stock_uom_in_job_card
erpnext.patches.v16_0.recalculate_purchase_receipt_billing_status
erpnext.patches.v16_0.repair_work_order_material_transfer
erpnext.patches.v16_0.remove_frappe_crm_custom_fields

View File

@@ -0,0 +1,27 @@
import frappe
from frappe.custom.doctype.custom_field.custom_field import delete_custom_fields
from erpnext.crm.doctype.crm_settings.crm_settings import CRMSettings
def execute():
"""Delete the `crm_deal` fields on Quotation and Customer if Frappe CRM Data Synchronization is disabled and there's no data on those fields."""
crm_deal_exists_in_quotation = frappe.db.has_column("Quotation", "crm_deal") and frappe.get_all(
"Quotation", filters={"crm_deal": ["is", "set"]}, limit=1
)
crm_deal_exists_in_customer = frappe.db.has_column("Customer", "crm_deal") and frappe.get_all(
"Customer", filters={"crm_deal": ["is", "set"]}, limit=1
)
enable_frappe_crm_data_sync = frappe.get_single_value(
"CRM Settings", "enable_frappe_crm_data_synchronization"
)
if enable_frappe_crm_data_sync or crm_deal_exists_in_quotation or crm_deal_exists_in_customer:
return
custom_fields = CRMSettings.get_frappe_crm_custom_fields()
delete_custom_fields(custom_fields)