diff --git a/crm/crm/doctype/crm_lead/crm_lead.py b/crm/crm/doctype/crm_lead/crm_lead.py index 90f0d0f3..c508f053 100644 --- a/crm/crm/doctype/crm_lead/crm_lead.py +++ b/crm/crm/doctype/crm_lead/crm_lead.py @@ -14,7 +14,8 @@ class CRMLead(Document): self.set_lead_name() self.set_title() self.validate_email() - self.validate_contact() + if not self.is_new(): + self.validate_contact() def set_full_name(self): if self.first_name: diff --git a/crm/twilio/api.py b/crm/twilio/api.py index ffbe7ebc..d44db9b7 100644 --- a/crm/twilio/api.py +++ b/crm/twilio/api.py @@ -84,6 +84,9 @@ def update_call_log(call_sid, status=None): call_log.duration = call_details.duration call_log.start_time = get_datetime_from_timestamp(call_details.start_time) call_log.end_time = get_datetime_from_timestamp(call_details.end_time) + call_log.lead = get_lead_from_number(call_log) + if call_log.note and call_log.lead: + frappe.db.set_value("CRM Note", call_log.note, "lead", call_log.lead) call_log.flags.ignore_permissions = True call_log.save() frappe.db.commit() @@ -137,4 +140,16 @@ def add_note_to_call_log(call_sid, note): if not twilio: return call_details = twilio.get_call_info(call_sid) - frappe.db.set_value("CRM Call Log", call_details.parent_call_sid, "note", note) \ No newline at end of file + frappe.db.set_value("CRM Call Log", call_details.parent_call_sid, "note", note) + frappe.db.commit() + +def get_lead_from_number(call): + """Get lead from the given number. + """ + lead = None + if call.type == 'Outgoing': + lead = frappe.db.get_value("CRM Lead", { "mobile_no": call.get('to') }) + else: + lead = frappe.db.get_value("CRM Lead", { "mobile_no": call.get('from') }) + + return lead \ No newline at end of file diff --git a/frappe-ui b/frappe-ui index 91670575..2d30e159 160000 --- a/frappe-ui +++ b/frappe-ui @@ -1 +1 @@ -Subproject commit 9167057574f2650e83360beb05ae25f0b6478211 +Subproject commit 2d30e159e20274011b87fa6077613557f302ec26 diff --git a/frontend/src/components/CallUI.vue b/frontend/src/components/CallUI.vue index 8f3265cd..a2e80342 100644 --- a/frontend/src/components/CallUI.vue +++ b/frontend/src/components/CallUI.vue @@ -362,6 +362,10 @@ function hangUpCall() { onCall.value = false callStatus.value = '' muted.value = false + note.value = { + title: '', + content: '', + } counterUp.value.stop() } @@ -375,6 +379,7 @@ function handleDisconnectedIncomingCall() { } _call.value = null muted.value = false + onCall.value = false counterUp.value.stop() } @@ -419,6 +424,10 @@ async function makeOutgoingCall(number) { callStatus.value = '' muted.value = false counterUp.value.stop() + note.value = { + title: '', + content: '', + } // update_call_log(conn) }) _call.value.on('cancel', () => { @@ -430,6 +439,10 @@ async function makeOutgoingCall(number) { _call.value = null callStatus.value = '' muted.value = false + note.value = { + title: '', + content: '', + } counterUp.value.stop() }) } catch (error) { @@ -452,6 +465,10 @@ function cancelCall() { onCall.value = false callStatus.value = '' muted.value = false + note.value = { + title: '', + content: '', + } } function toggleCallWindow() { diff --git a/frontend/src/pages/CallLog.vue b/frontend/src/pages/CallLog.vue index fd864628..f1f3de20 100644 --- a/frontend/src/pages/CallLog.vue +++ b/frontend/src/pages/CallLog.vue @@ -22,7 +22,7 @@