fix: added employee name to call log

This commit is contained in:
Subin Tom 2022-02-23 18:45:50 +05:30
parent 8d3011832b
commit 006606c437
2 changed files with 21 additions and 2 deletions

View File

@ -1,7 +1,7 @@
{ {
"actions": [], "actions": [],
"autoname": "field:id", "autoname": "field:id",
"creation": "2019-06-05 12:07:02.634534", "creation": "2022-02-21 11:54:58.414784",
"doctype": "DocType", "doctype": "DocType",
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
@ -9,6 +9,7 @@
"id", "id",
"from", "from",
"to", "to",
"employee_call_directed_to",
"medium", "medium",
"start_time", "start_time",
"end_time", "end_time",
@ -134,15 +135,23 @@
"fieldname": "call_details_section", "fieldname": "call_details_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Call Details" "label": "Call Details"
},
{
"depends_on": "to",
"fieldname": "employee_call_directed_to",
"fieldtype": "Data",
"label": "Employee Call Directed To",
"read_only": 1
} }
], ],
"in_create": 1, "in_create": 1,
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2021-02-08 14:23:28.744844", "modified": "2022-02-23 18:45:06.932571",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Telephony", "module": "Telephony",
"name": "Call Log", "name": "Call Log",
"naming_rule": "By fieldname",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
@ -164,6 +173,7 @@
], ],
"sort_field": "creation", "sort_field": "creation",
"sort_order": "DESC", "sort_order": "DESC",
"states": [],
"title_field": "from", "title_field": "from",
"track_changes": 1, "track_changes": 1,
"track_views": 1 "track_views": 1

View File

@ -33,6 +33,15 @@ class CallLog(Document):
if lead: if lead:
self.add_link(link_type='Lead', link_name=lead) self.add_link(link_type='Lead', link_name=lead)
# Add Employee Name
if self.is_incoming_call():
# Taking the last 10 digits of the number
emp_number_reversed = (self.get("to"))[-1:-11:-1]
emp_number = emp_number_reversed[-1::-1]
emp_name = frappe.get_all("Employee", filters={"cell_number":["like","%"+emp_number+"%"]}, fields=["first_name", "middle_name", "last_name"])
self.employee_call_directed_to = (emp_name[0].get("first_name") or '') + ' ' + (emp_name[0].get("middle_name") or '') + ' ' + (emp_name[0].get("last_name") or '')
def after_insert(self): def after_insert(self):
self.trigger_call_popup() self.trigger_call_popup()