1
0
forked from test/crm

Merge pull request #125 from shariquerik/minor-fix-1

fix: minor fixes
This commit is contained in:
Shariq Ansari 2024-04-08 18:25:03 +05:30 committed by GitHub
commit abc4ecc65b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 39 additions and 32 deletions

View File

@ -88,6 +88,43 @@ def get_call_log(name):
"content": note[1]
}
def get_contact(number):
c = frappe.db.get_value("Contact", {"mobile_no": number}, ["full_name", "image"], as_dict=True)
if c:
return [c.full_name, c.image]
return [None, None]
def get_lead_contact(number):
l = frappe.db.get_value("CRM Lead", {"mobile_no": number, "converted": 0}, ["lead_name", "image"], as_dict=True)
if l:
return [l.lead_name, l.image]
return [None, None]
def get_user(user):
u = frappe.db.get_value("User", user, ["full_name", "user_image"], as_dict=True)
if u:
return [u.full_name, u.user_image]
return [None, None]
if doc.type == "Incoming":
doc.caller = {
"label": get_contact(doc.get("from"))[0] or get_lead_contact(doc.get("from"))[0] or "Unknown",
"image": get_contact(doc.get("from"))[1] or get_lead_contact(doc.get("from"))[1]
}
doc.receiver = {
"label": get_user(doc.get("receiver"))[0],
"image": get_user(doc.get("receiver"))[1]
}
else:
doc.caller = {
"label": get_user(doc.get("caller"))[0],
"image": get_user(doc.get("caller"))[1]
}
doc.receiver = {
"label": get_contact(doc.get("to"))[0] or get_lead_contact(doc.get("to"))[0] or "Unknown",
"image": get_contact(doc.get("to"))[1] or get_lead_contact(doc.get("to"))[1]
}
return doc
@frappe.whitelist()

View File

@ -262,6 +262,6 @@ class TwilioCallDetails:
'id': self.call_sid,
'from': from_number,
'to': to_number,
'reciever': receiver,
'receiver': receiver,
'caller': caller,
}

View File

@ -46,7 +46,7 @@
<div id="value" class="!min-w-[140px]">
<component
:is="getValSelect(f)"
:value="f.value"
v-model="f.value"
@change="(v) => updateValue(v, f)"
placeholder="Value"
/>

View File

@ -157,14 +157,10 @@ import {
createResource,
Breadcrumbs,
} from 'frappe-ui'
import { usersStore } from '@/stores/users'
import { contactsStore } from '@/stores/contacts'
import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const { getUser } = usersStore()
const { contacts, getContact, getLeadContact } = contactsStore()
const props = defineProps({
callLogId: {
@ -184,31 +180,6 @@ const callLog = createResource({
},
transform: (doc) => {
doc.duration = secondsToDuration(doc.duration)
if (doc.type === 'Incoming') {
doc.caller = {
label:
getContact(doc.from)?.full_name ||
getLeadContact(doc.from)?.full_name ||
'Unknown',
image: getContact(doc.from)?.image || getLeadContact(doc.from)?.image,
}
doc.receiver = {
label: getUser(doc.receiver).full_name,
image: getUser(doc.receiver).user_image,
}
} else {
doc.caller = {
label: getUser(doc.caller).full_name,
image: getUser(doc.caller).user_image,
}
doc.receiver = {
label:
getContact(doc.to)?.full_name ||
getLeadContact(doc.to)?.full_name ||
'Unknown',
image: getContact(doc.to)?.image || getLeadContact(doc.to)?.image,
}
}
return doc
},
})
@ -232,7 +203,6 @@ function createLead() {
}).then((d) => {
if (d) {
callLog.reload()
contacts.reload()
router.push({ name: 'Lead', params: { leadId: d } })
}
})