From f7bcc4b910a0a76a6a5372431ea9f7d362f07f27 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 11 Jul 2025 16:16:40 +0530 Subject: [PATCH] patch: added patch to update deal status type (cherry picked from commit 4e6d4a1d77b062c531b8c84634c312b6cb3537fe) --- crm/patches.txt | 3 +- crm/patches/v1_0/update_deal_status_type.py | 44 +++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 crm/patches/v1_0/update_deal_status_type.py diff --git a/crm/patches.txt b/crm/patches.txt index 484c73dc..910f0fe1 100644 --- a/crm/patches.txt +++ b/crm/patches.txt @@ -13,4 +13,5 @@ crm.patches.v1_0.update_deal_quick_entry_layout crm.patches.v1_0.update_layouts_to_new_format crm.patches.v1_0.move_twilio_agent_to_telephony_agent crm.patches.v1_0.create_default_scripts # 13-06-2025 -crm.patches.v1_0.update_deal_status_probabilities \ No newline at end of file +crm.patches.v1_0.update_deal_status_probabilities +crm.patches.v1_0.update_deal_status_type \ No newline at end of file diff --git a/crm/patches/v1_0/update_deal_status_type.py b/crm/patches/v1_0/update_deal_status_type.py new file mode 100644 index 00000000..230f3776 --- /dev/null +++ b/crm/patches/v1_0/update_deal_status_type.py @@ -0,0 +1,44 @@ +import frappe + + +def execute(): + deal_statuses = frappe.get_all("CRM Deal Status", fields=["name", "type", "deal_status"]) + + openStatuses = ["New", "Open", "Unassigned", "Qualification"] + ongoingStatuses = [ + "Demo/Making", + "Proposal/Quotation", + "Negotiation", + "Ready to Close", + "Demo Scheduled", + "Follow Up", + ] + onHoldStatuses = ["On Hold", "Paused", "Stalled", "Awaiting Reply"] + wonStatuses = ["Won", "Closed Won", "Successful", "Completed"] + lostStatuses = [ + "Lost", + "Closed", + "Closed Lost", + "Junk", + "Unqualified", + "Disqualified", + "Cancelled", + "No Response", + ] + + for status in deal_statuses: + if status.type is None or status.type == "": + if status.deal_status in openStatuses: + type = "Open" + elif status.deal_status in ongoingStatuses: + type = "Ongoing" + elif status.deal_status in onHoldStatuses: + type = "On Hold" + elif status.deal_status in wonStatuses: + type = "Won" + elif status.deal_status in lostStatuses: + type = "Lost" + else: + type = "Ongoing" + + frappe.db.set_value("CRM Deal Status", status.name, "type", type)