fix: update lead/note/call based on contact
This commit is contained in:
parent
20f3c089aa
commit
7526612ffe
@ -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:
|
||||
|
||||
@ -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)
|
||||
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
|
||||
@ -1 +1 @@
|
||||
Subproject commit 9167057574f2650e83360beb05ae25f0b6478211
|
||||
Subproject commit 2d30e159e20274011b87fa6077613557f302ec26
|
||||
@ -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() {
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<div class="text-sm text-gray-900">{{ callLog.doc[field.key] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-3 pb-1 text-base font-medium mt-3">Call note</div>
|
||||
<!-- <div class="px-3 pb-1 text-base font-medium mt-3">Call note</div>
|
||||
<div v-if="callNote?.doc" class="flex flex-col p-3">
|
||||
<TextInput
|
||||
type="text"
|
||||
@ -38,7 +38,7 @@
|
||||
@change="(val) => (callNote.doc.content = val)"
|
||||
placeholder="Type something and press enter"
|
||||
/>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -116,20 +116,21 @@ const details = {
|
||||
],
|
||||
}
|
||||
|
||||
const callNote = computed(() => {
|
||||
return createDocumentResource({
|
||||
doctype: 'CRM Note',
|
||||
name: callLog.doc?.note,
|
||||
auto: true,
|
||||
setValue: {},
|
||||
})
|
||||
})
|
||||
// const callNote = computed(() => {
|
||||
// return createDocumentResource({
|
||||
// doctype: 'CRM Note',
|
||||
// name: callLog.doc?.note,
|
||||
// auto: true,
|
||||
// setValue: {},
|
||||
// })
|
||||
// })
|
||||
|
||||
async function createLead() {
|
||||
let d = await call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: 'CRM Lead',
|
||||
lead_name: 'Lead from call',
|
||||
first_name: "Lead from " + callLog.doc.from,
|
||||
mobile_no: callLog.doc.from,
|
||||
},
|
||||
})
|
||||
if (d.name) {
|
||||
@ -140,7 +141,12 @@ async function createLead() {
|
||||
}
|
||||
|
||||
async function update_note(lead) {
|
||||
callNote.value.setValue.submit({ lead: lead })
|
||||
await call('frappe.client.set_value', {
|
||||
doctype: 'CRM Note',
|
||||
name: callLog.doc?.note,
|
||||
fieldname: 'lead',
|
||||
value: lead,
|
||||
})
|
||||
}
|
||||
|
||||
async function update_call_log(lead) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user