mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
fix: Add code to update call summary
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
from frappe import _
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -53,7 +54,7 @@ def get_last_interaction(number, reference_doc):
|
|||||||
if customer_name:
|
if customer_name:
|
||||||
last_issue = frappe.get_all('Issue', {
|
last_issue = frappe.get_all('Issue', {
|
||||||
'customer': customer_name
|
'customer': customer_name
|
||||||
}, ['name', 'subject'], limit=1)
|
}, ['name', 'subject', 'customer'], limit=1)
|
||||||
|
|
||||||
elif reference_doc.doctype == 'Lead':
|
elif reference_doc.doctype == 'Lead':
|
||||||
last_communication = frappe.get_all('Communication', {
|
last_communication = frappe.get_all('Communication', {
|
||||||
@@ -70,9 +71,11 @@ def get_last_interaction(number, reference_doc):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_call_summary(docname, summary):
|
def add_call_summary(docname, summary):
|
||||||
communication = frappe.get_doc('Communication', docname)
|
communication = frappe.get_doc('Communication', docname)
|
||||||
communication.content = 'Call Summary by {user}: {summary}'.format({
|
content = _('Call Summary by {0}: {1}').format(
|
||||||
'user': frappe.utils.get_fullname(frappe.session.user),
|
frappe.utils.get_fullname(frappe.session.user), summary)
|
||||||
'summary': summary
|
if not communication.content:
|
||||||
})
|
communication.content = content
|
||||||
|
else:
|
||||||
|
communication.content += '\n' + content
|
||||||
communication.save(ignore_permissions=True)
|
communication.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,14 @@ def handle_incoming_call(*args, **kwargs):
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def handle_end_call(*args, **kwargs):
|
def handle_end_call(*args, **kwargs):
|
||||||
call_log = get_call_log(kwargs)
|
close_call_log(kwargs)
|
||||||
|
|
||||||
|
@frappe.whitelist(allow_guest=True)
|
||||||
|
def handle_missed_call(*args, **kwargs):
|
||||||
|
close_call_log(kwargs)
|
||||||
|
|
||||||
|
def close_call_log(call_payload):
|
||||||
|
call_log = get_call_log(call_payload)
|
||||||
if call_log:
|
if call_log:
|
||||||
call_log.status = 'Closed'
|
call_log.status = 'Closed'
|
||||||
call_log.save(ignore_permissions=True)
|
call_log.save(ignore_permissions=True)
|
||||||
@@ -82,6 +89,7 @@ def make_a_call(from_number, to_number, caller_id):
|
|||||||
response = requests.post('https://{api_key}:{api_token}@api.exotel.com/v1/Accounts/{sid}/Calls/connect.json?details=true'.format(
|
response = requests.post('https://{api_key}:{api_token}@api.exotel.com/v1/Accounts/{sid}/Calls/connect.json?details=true'.format(
|
||||||
api_key=settings.api_key,
|
api_key=settings.api_key,
|
||||||
api_token=settings.api_token,
|
api_token=settings.api_token,
|
||||||
|
sid=settings.account_sid
|
||||||
), data={
|
), data={
|
||||||
'From': from_number,
|
'From': from_number,
|
||||||
'To': to_number,
|
'To': to_number,
|
||||||
@@ -91,4 +99,24 @@ def make_a_call(from_number, to_number, caller_id):
|
|||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def get_exotel_settings():
|
def get_exotel_settings():
|
||||||
return frappe.get_single('Exotel Settings')
|
return frappe.get_single('Exotel Settings')
|
||||||
|
|
||||||
|
@frappe.whitelist(allow_guest=True)
|
||||||
|
def get_phone_numbers():
|
||||||
|
numbers = 'some number'
|
||||||
|
whitelist_numbers(numbers, 'for number')
|
||||||
|
return numbers
|
||||||
|
|
||||||
|
def whitelist_numbers(numbers, caller_id):
|
||||||
|
settings = get_exotel_settings()
|
||||||
|
query = 'https://{api_key}:{api_token}@api.exotel.com/v1/Accounts/{sid}/CustomerWhitelist'.format(
|
||||||
|
api_key=settings.api_key,
|
||||||
|
api_token=settings.api_token,
|
||||||
|
sid=settings.account_sid
|
||||||
|
)
|
||||||
|
response = requests.post(query, data={
|
||||||
|
'VirtualNumber': caller_id,
|
||||||
|
'Number': numbers,
|
||||||
|
})
|
||||||
|
|
||||||
|
return response
|
||||||
@@ -43,9 +43,10 @@ class CallPopup {
|
|||||||
'label': 'Submit',
|
'label': 'Submit',
|
||||||
'click': () => {
|
'click': () => {
|
||||||
const values = this.dialog.get_values();
|
const values = this.dialog.get_values();
|
||||||
|
if (!values.call_summary) return
|
||||||
frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
|
frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
|
||||||
'docname': this.call_log.name,
|
'docname': this.call_log.name,
|
||||||
'summary': `${__('Call Summary')}: ${values.call_summary}`,
|
'summary': values.call_summary,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.dialog.set_value('call_summary', '');
|
this.dialog.set_value('call_summary', '');
|
||||||
});
|
});
|
||||||
@@ -62,6 +63,7 @@ class CallPopup {
|
|||||||
this.dialog.$body.addClass('call-popup');
|
this.dialog.$body.addClass('call-popup');
|
||||||
this.dialog.set_secondary_action(() => {
|
this.dialog.set_secondary_action(() => {
|
||||||
clearInterval(this.updater);
|
clearInterval(this.updater);
|
||||||
|
delete erpnext.call_popup;
|
||||||
this.dialog.hide();
|
this.dialog.hide();
|
||||||
});
|
});
|
||||||
this.dialog.show();
|
this.dialog.show();
|
||||||
@@ -173,7 +175,7 @@ class CallPopup {
|
|||||||
const issue_field = this.dialog.fields_dict["last_issue"];
|
const issue_field = this.dialog.fields_dict["last_issue"];
|
||||||
issue_field.set_value(issue.subject);
|
issue_field.set_value(issue.subject);
|
||||||
issue_field.$wrapper
|
issue_field.$wrapper
|
||||||
.append(`<a class="text-medium" href="#Form/Issue/${issue.name}">View ${issue.name}</a>`);
|
.append(`<a class="text-medium" href="#List/Issue/List?customer=${issue.customer}">View all issues from ${issue.customer}</a>`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user