fix: Add code to update call summary
diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py
index 9399fba..26cb298 100644
--- a/erpnext/crm/doctype/utils.py
+++ b/erpnext/crm/doctype/utils.py
@@ -1,4 +1,5 @@
import frappe
+from frappe import _
import json
@frappe.whitelist()
@@ -53,7 +54,7 @@
if customer_name:
last_issue = frappe.get_all('Issue', {
'customer': customer_name
- }, ['name', 'subject'], limit=1)
+ }, ['name', 'subject', 'customer'], limit=1)
elif reference_doc.doctype == 'Lead':
last_communication = frappe.get_all('Communication', {
@@ -70,9 +71,11 @@
@frappe.whitelist()
def add_call_summary(docname, summary):
communication = frappe.get_doc('Communication', docname)
- communication.content = 'Call Summary by {user}: {summary}'.format({
- 'user': frappe.utils.get_fullname(frappe.session.user),
- 'summary': summary
- })
+ content = _('Call Summary by {0}: {1}').format(
+ frappe.utils.get_fullname(frappe.session.user), summary)
+ if not communication.content:
+ communication.content = content
+ else:
+ communication.content += '\n' + content
communication.save(ignore_permissions=True)
diff --git a/erpnext/erpnext_integrations/exotel_integration.py b/erpnext/erpnext_integrations/exotel_integration.py
index 5b24e7c..c70b094 100644
--- a/erpnext/erpnext_integrations/exotel_integration.py
+++ b/erpnext/erpnext_integrations/exotel_integration.py
@@ -32,7 +32,14 @@
@frappe.whitelist(allow_guest=True)
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:
call_log.status = 'Closed'
call_log.save(ignore_permissions=True)
@@ -82,6 +89,7 @@
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_token=settings.api_token,
+ sid=settings.account_sid
), data={
'From': from_number,
'To': to_number,
@@ -91,4 +99,24 @@
return response.json()
def get_exotel_settings():
- return frappe.get_single('Exotel Settings')
\ No newline at end of file
+ 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
\ No newline at end of file
diff --git a/erpnext/public/js/call_popup/call_popup.js b/erpnext/public/js/call_popup/call_popup.js
index 2410684..5693ff0 100644
--- a/erpnext/public/js/call_popup/call_popup.js
+++ b/erpnext/public/js/call_popup/call_popup.js
@@ -43,9 +43,10 @@
'label': 'Submit',
'click': () => {
const values = this.dialog.get_values();
+ if (!values.call_summary) return
frappe.xcall('erpnext.crm.doctype.utils.add_call_summary', {
'docname': this.call_log.name,
- 'summary': `${__('Call Summary')}: ${values.call_summary}`,
+ 'summary': values.call_summary,
}).then(() => {
this.dialog.set_value('call_summary', '');
});
@@ -62,6 +63,7 @@
this.dialog.$body.addClass('call-popup');
this.dialog.set_secondary_action(() => {
clearInterval(this.updater);
+ delete erpnext.call_popup;
this.dialog.hide();
});
this.dialog.show();
@@ -173,7 +175,7 @@
const issue_field = this.dialog.fields_dict["last_issue"];
issue_field.set_value(issue.subject);
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>`);
}
});
}