From 44c0e9d54901c80b4fe780453e6dc4a7eac24eff Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 Jun 2019 11:18:16 +0530 Subject: [PATCH] fix: Create call log instead of communication --- erpnext/crm/doctype/utils.py | 11 ++++---- .../exotel_integration.py | 27 +++++++------------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py index 26cb2981d83..93d440cccb2 100644 --- a/erpnext/crm/doctype/utils.py +++ b/erpnext/crm/doctype/utils.py @@ -70,12 +70,13 @@ def get_last_interaction(number, reference_doc): @frappe.whitelist() def add_call_summary(docname, summary): - communication = frappe.get_doc('Communication', docname) + call_log = frappe.get_doc('Call Log', docname) content = _('Call Summary by {0}: {1}').format( frappe.utils.get_fullname(frappe.session.user), summary) - if not communication.content: - communication.content = content + if not call_log.call_summary: + call_log.call_summary = content else: - communication.content += '\n' + content - communication.save(ignore_permissions=True) + call_log.call_summary += '
' + content + call_log.save(ignore_permissions=True) + diff --git a/erpnext/erpnext_integrations/exotel_integration.py b/erpnext/erpnext_integrations/exotel_integration.py index c70b0948aef..358eb3be0cd 100644 --- a/erpnext/erpnext_integrations/exotel_integration.py +++ b/erpnext/erpnext_integrations/exotel_integration.py @@ -47,29 +47,20 @@ def close_call_log(call_payload): def get_call_log(call_payload, create_new_if_not_found=True): - communication = frappe.get_all('Communication', { - 'communication_medium': 'Phone', + call_log = frappe.get_all('Call Log', { 'call_id': call_payload.get('CallSid'), }, limit=1) - if communication: - communication = frappe.get_doc('Communication', communication[0].name) - return communication + if call_log: + return frappe.get_doc('Call Log', call_log[0].name) elif create_new_if_not_found: - communication = frappe.new_doc('Communication') - communication.subject = frappe._('Call from {}').format(call_payload.get("CallFrom")) - communication.communication_medium = 'Phone' - communication.phone_no = call_payload.get("CallFrom") - communication.comment_type = 'Info' - communication.communication_type = 'Communication' - communication.sent_or_received = 'Received' - communication.communication_date = call_payload.get('StartTime') - communication.call_id = call_payload.get('CallSid') - communication.status = 'Open' - communication.content = frappe._('Call from {}').format(call_payload.get("CallFrom")) - communication.save(ignore_permissions=True) + call_log = frappe.new_doc('Call Log') + call_log.call_id = call_payload.get('CallSid') + call_log.call_from = call_payload.get('CallFrom') + call_log.status = 'Ringing' + call_log.save(ignore_permissions=True) frappe.db.commit() - return communication + return call_log @frappe.whitelist() def get_call_status(call_id):