-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch: Rename Twilio Settings to CRM Twilio Settings
Move Twilio Agent to Telephony Agent
- Loading branch information
1 parent
89dd093
commit 97b67cf
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
crm/patches/v1_0/rename_twilio_settings_to_crm_twilio_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |