Skip to content

Commit

Permalink
patch: Rename Twilio Settings to CRM Twilio Settings
Browse files Browse the repository at this point in the history
Move Twilio Agent to Telephony Agent
  • Loading branch information
shariquerik committed Jan 19, 2025
1 parent 89dd093 commit 97b67cf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crm/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# 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.move_crm_note_data_to_fcrm_note
crm.patches.v1_0.rename_twilio_settings_to_crm_twilio_settings

[post_model_sync]
# Patches added in this section will be executed after doctypes are migrated
crm.patches.v1_0.create_email_template_custom_fields
crm.patches.v1_0.create_default_fields_layout #10/12/2024
crm.patches.v1_0.create_default_sidebar_fields_layout
crm.patches.v1_0.update_deal_quick_entry_layout
crm.patches.v1_0.update_layouts_to_new_format
crm.patches.v1_0.update_layouts_to_new_format
crm.patches.v1_0.move_twilio_agent_to_telephony_agent
27 changes: 27 additions & 0 deletions crm/patches/v1_0/move_twilio_agent_to_telephony_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import frappe


def execute():
if not frappe.db.exists("DocType", "CRM Telephony Agent"):
frappe.reload_doctype("CRM Telephony Agent", force=True)

if frappe.db.exists("DocType", "Twilio Agents") and frappe.db.count("Twilio Agents") == 0:
return

agents = frappe.db.sql("SELECT * FROM `tabTwilio Agents`", as_dict=True)
if agents:
for agent in agents:
doc = frappe.get_doc(
{
"doctype": "CRM Telephony Agent",
"creation": agent.get("creation"),
"modified": agent.get("modified"),
"modified_by": agent.get("modified_by"),
"owner": agent.get("owner"),
"user": agent.get("user"),
"twilio_number": agent.get("twilio_number"),
"user_name": agent.get("user_name"),
"twilio": True,
}
)
doc.db_insert()
11 changes: 11 additions & 0 deletions crm/patches/v1_0/rename_twilio_settings_to_crm_twilio_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import frappe
from frappe.model.rename_doc import rename_doc


def execute():
if frappe.db.table_exists("Twilio Settings"):
frappe.flags.ignore_route_conflict_validation = True
rename_doc("DocType", "Twilio Settings", "CRM Twilio Settings")
frappe.flags.ignore_route_conflict_validation = False

frappe.reload_doctype("CRM Twilio Settings", force=True)

0 comments on commit 97b67cf

Please sign in to comment.