Merge branch 'call-summary-dialog' of github.com:surajshetty3416/erpnext into call-summary-dialog
diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py
index 5f7a72e..bd8b678 100644
--- a/erpnext/crm/doctype/utils.py
+++ b/erpnext/crm/doctype/utils.py
@@ -82,12 +82,14 @@
now_time = frappe.utils.nowtime()
weekday = frappe.utils.get_weekday()
- available_employee_groups = frappe.db.sql_list("""SELECT `employee_group`
- FROM `tabCommunication Medium Timeslot`
- WHERE `day_of_week` = %s
- AND `parent` = %s
- AND %s BETWEEN `from_time` AND `to_time`
- """, (weekday, communication_medium, now_time))
+ available_employee_groups = frappe.get_all("Communication Medium Timeslot", filters={
+ 'day_of_week': weekday,
+ 'parent': communication_medium,
+ 'from_time': ['<=', now_time],
+ 'to_time': ['>=', now_time],
+ }, fields=['employee_group'], debug=1)
+
+ available_employee_groups = tuple([emp.employee_group for emp in available_employee_groups])
employees = frappe.get_all('Employee Group Table', filters={
'parent': ['in', available_employee_groups]
diff --git a/erpnext/erpnext_integrations/exotel_integration.py b/erpnext/erpnext_integrations/exotel_integration.py
index a427186..c04cedc 100644
--- a/erpnext/erpnext_integrations/exotel_integration.py
+++ b/erpnext/erpnext_integrations/exotel_integration.py
@@ -6,26 +6,29 @@
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_missed_call
@frappe.whitelist(allow_guest=True)
-def handle_incoming_call(*args, **kwargs):
+def handle_incoming_call(**kwargs):
exotel_settings = get_exotel_settings()
if not exotel_settings.enabled: return
- status = kwargs.get('Status')
+ call_payload = kwargs
+ status = call_payload.get('Status')
if status == 'free':
return
- create_call_log(kwargs)
+ call_log = get_call_log(call_payload)
+ if not call_log:
+ create_call_log(call_payload)
@frappe.whitelist(allow_guest=True)
-def handle_end_call(*args, **kwargs):
+def handle_end_call(**kwargs):
update_call_log(kwargs, 'Completed')
@frappe.whitelist(allow_guest=True)
-def handle_missed_call(*args, **kwargs):
+def handle_missed_call(**kwargs):
update_call_log(kwargs, 'Missed')
def update_call_log(call_payload, status):
- call_log = get_call_log(call_payload, False)
+ call_log = get_call_log(call_payload)
if call_log:
call_log.status = status
call_log.duration = call_payload.get('DialCallDuration') or 0
@@ -34,25 +37,24 @@
frappe.db.commit()
return call_log
-def get_call_log(call_payload, create_new_if_not_found=True):
+def get_call_log(call_payload):
call_log = frappe.get_all('Call Log', {
'id': call_payload.get('CallSid'),
}, limit=1)
if call_log:
return frappe.get_doc('Call Log', call_log[0].name)
- elif create_new_if_not_found:
- call_log = frappe.new_doc('Call Log')
- call_log.id = call_payload.get('CallSid')
- call_log.to = call_payload.get('CallTo')
- call_log.medium = call_payload.get('To')
- call_log.status = 'Ringing'
- setattr(call_log, 'from', call_payload.get('CallFrom'))
- call_log.save(ignore_permissions=True)
- frappe.db.commit()
- return call_log
-create_call_log = get_call_log
+def create_call_log(call_payload):
+ call_log = frappe.new_doc('Call Log')
+ call_log.id = call_payload.get('CallSid')
+ call_log.to = call_payload.get('CallTo')
+ call_log.medium = call_payload.get('To')
+ call_log.status = 'Ringing'
+ setattr(call_log, 'from', call_payload.get('CallFrom'))
+ call_log.save(ignore_permissions=True)
+ frappe.db.commit()
+ return call_log
@frappe.whitelist()
def get_call_status(call_id):
diff --git a/erpnext/public/js/call_popup/call_popup.js b/erpnext/public/js/call_popup/call_popup.js
index 17bd741..91dfe80 100644
--- a/erpnext/public/js/call_popup/call_popup.js
+++ b/erpnext/public/js/call_popup/call_popup.js
@@ -64,8 +64,8 @@
}
make_caller_info_section() {
- const wrapper = this.dialog.fields_dict['caller_info'].$wrapper;
- wrapper.append('<div class="text-muted"> Loading... </div>');
+ const wrapper = this.dialog.get_field('caller_info').$wrapper;
+ wrapper.append(`<div class="text-muted"> ${__("Loading...")} </div>`);
frappe.xcall('erpnext.crm.doctype.utils.get_document_with_phone_number', {
'number': this.caller_number
}).then(contact_doc => {
@@ -88,7 +88,7 @@
<button
class="margin-left btn btn-new btn-default btn-xs"
data-doctype="Contact"
- title="Make New Contact">
+ title=${__("Make New Contact")}>
<i class="octicon octicon-plus text-medium"></i>
</button>
</div>
@@ -172,7 +172,7 @@
'number': this.caller_number,
'reference_doc': this.contact
}).then(data => {
- const comm_field = this.dialog.fields_dict["last_communication"];
+ const comm_field = this.dialog.get_field('last_communication');
if (data.last_communication) {
const comm = data.last_communication;
comm_field.set_value(comm.content);
@@ -180,7 +180,7 @@
if (data.last_issue) {
const issue = data.last_issue;
- const issue_field = this.dialog.fields_dict["last_issue"];
+ const issue_field = this.dialog.get_field("last_issue");
issue_field.set_value(issue.subject);
issue_field.$wrapper.append(`<a class="text-medium" href="#List/Issue?customer=${issue.customer}">
${__('View all issues from {0}', [issue.customer])}