fix: Employee selection for call popup
- Check if employee with matched number is also
scheduled to receive popup
diff --git a/erpnext/communication/doctype/call_log/call_log.py b/erpnext/communication/doctype/call_log/call_log.py
index cf5c12e..d29794e 100644
--- a/erpnext/communication/doctype/call_log/call_log.py
+++ b/erpnext/communication/doctype/call_log/call_log.py
@@ -6,7 +6,7 @@
import frappe
from frappe import _
from frappe.model.document import Document
-from erpnext.crm.doctype.utils import get_employee_emails_for_popup
+from erpnext.crm.doctype.utils import get_scheduled_employees_for_popup
from frappe.contacts.doctype.contact.contact import get_contact_with_phone_number
from erpnext.crm.doctype.lead.lead import get_lead_with_phone_number
@@ -28,8 +28,16 @@
self.trigger_call_popup()
def trigger_call_popup(self):
- employee_emails = get_employee_emails(self.to)
- for email in employee_emails:
+ scheduled_employees = get_scheduled_employees_for_popup(self.to)
+ employee_emails = get_employees_with_number(self.to)
+
+ # check if employees with matched number are scheduled to receive popup
+ emails = set(scheduled_employees).intersection(employee_emails)
+
+ # # if no employee found with matching phone number then show popup to scheduled employees
+ # emails = emails or scheduled_employees if employee_emails
+
+ for email in emails:
frappe.publish_realtime('show_call_popup', self, user=email)
@frappe.whitelist()
@@ -37,9 +45,8 @@
doc = frappe.get_doc('Call Log', call_log)
doc.add_comment('Comment', frappe.bold(_('Call Summary')) + '<br><br>' + summary)
-def get_employee_emails(number):
- '''Returns employee's emails of employees that have passed phone number'''
- if not number: return
+def get_employees_with_number(number):
+ if not number: return []
employee_emails = frappe.cache().hget('employees_with_number', number)
if employee_emails: return employee_emails
diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py
index c809469..1cfd89c 100644
--- a/erpnext/crm/doctype/utils.py
+++ b/erpnext/crm/doctype/utils.py
@@ -52,7 +52,7 @@
return issues[0] if issues else None
-def get_employee_emails_for_popup(communication_medium):
+def get_scheduled_employees_for_popup(communication_medium):
now_time = frappe.utils.nowtime()
weekday = frappe.utils.get_weekday()