fix: Create call log instead of communication

This commit is contained in:
Suraj Shetty 2019-06-06 11:18:16 +05:30
parent 27234ff907
commit 44c0e9d549
2 changed files with 15 additions and 23 deletions

View File

@ -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 += '<br>' + content
call_log.save(ignore_permissions=True)

View File

@ -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):