fix: get linked deals in contact
This commit is contained in:
parent
318a497886
commit
e286551bca
@ -15,6 +15,7 @@ def set_primary_email(doc):
|
|||||||
if len(doc.email_ids) == 1:
|
if len(doc.email_ids) == 1:
|
||||||
doc.email_ids[0].is_primary = 1
|
doc.email_ids[0].is_primary = 1
|
||||||
|
|
||||||
|
|
||||||
def set_primary_mobile_no(doc):
|
def set_primary_mobile_no(doc):
|
||||||
if not doc.phone_nos:
|
if not doc.phone_nos:
|
||||||
return
|
return
|
||||||
@ -22,6 +23,43 @@ def set_primary_mobile_no(doc):
|
|||||||
if len(doc.phone_nos) == 1:
|
if len(doc.phone_nos) == 1:
|
||||||
doc.phone_nos[0].is_primary_mobile_no = 1
|
doc.phone_nos[0].is_primary_mobile_no = 1
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_linked_deals(contact):
|
||||||
|
"""Get linked deals for a contact"""
|
||||||
|
|
||||||
|
if not frappe.has_permission("Contact", "read", contact):
|
||||||
|
frappe.throw("Not permitted", frappe.PermissionError)
|
||||||
|
|
||||||
|
deal_names = frappe.get_all(
|
||||||
|
"CRM Contacts",
|
||||||
|
filters={"contact": contact, "parenttype": "CRM Deal"},
|
||||||
|
fields=["parent"],
|
||||||
|
distinct=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# get deals data
|
||||||
|
deals = []
|
||||||
|
for d in deal_names:
|
||||||
|
deal = frappe.get_cached_doc(
|
||||||
|
"CRM Deal",
|
||||||
|
d.parent,
|
||||||
|
fields=[
|
||||||
|
"name",
|
||||||
|
"organization",
|
||||||
|
"annual_revenue",
|
||||||
|
"status",
|
||||||
|
"email",
|
||||||
|
"mobile_no",
|
||||||
|
"deal_owner",
|
||||||
|
"modified",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
deals.append(deal.as_dict())
|
||||||
|
|
||||||
|
return deals
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_new(contact, field, value):
|
def create_new(contact, field, value):
|
||||||
"""Create new email or phone for a contact"""
|
"""Create new email or phone for a contact"""
|
||||||
|
|||||||
@ -357,25 +357,12 @@ const leads = createListResource({
|
|||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const deals = createListResource({
|
const deals = createResource({
|
||||||
type: 'list',
|
url: 'crm.api.contact.get_linked_deals',
|
||||||
doctype: 'CRM Deal',
|
|
||||||
cache: ['deals', props.contactId],
|
cache: ['deals', props.contactId],
|
||||||
fields: [
|
params: {
|
||||||
'name',
|
contact: props.contactId,
|
||||||
'organization',
|
|
||||||
'annual_revenue',
|
|
||||||
'status',
|
|
||||||
'email',
|
|
||||||
'mobile_no',
|
|
||||||
'deal_owner',
|
|
||||||
'modified',
|
|
||||||
],
|
|
||||||
filters: {
|
|
||||||
email: contact.value?.email_id,
|
|
||||||
},
|
},
|
||||||
orderBy: 'modified desc',
|
|
||||||
pageLength: 20,
|
|
||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user