fix: Last communication query
This commit is contained in:
parent
f5dd494716
commit
e7d277d51e
@ -145,13 +145,8 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"email": 1,
|
|
||||||
"export": 1,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"role": "Employee"
|
||||||
"role": "Employee",
|
|
||||||
"share": 1
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
|
@ -20,7 +20,7 @@ def get_last_interaction(contact=None, lead=None):
|
|||||||
if query_condition:
|
if query_condition:
|
||||||
# remove extra appended 'OR'
|
# remove extra appended 'OR'
|
||||||
query_condition = query_condition[:-2]
|
query_condition = query_condition[:-2]
|
||||||
communication = frappe.db.sql("""
|
last_communication = frappe.db.sql("""
|
||||||
SELECT `name`, `content`
|
SELECT `name`, `content`
|
||||||
FROM `tabCommunication`
|
FROM `tabCommunication`
|
||||||
WHERE
|
WHERE
|
||||||
@ -28,12 +28,12 @@ def get_last_interaction(contact=None, lead=None):
|
|||||||
({})
|
({})
|
||||||
ORDER BY `modified`
|
ORDER BY `modified`
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
""".format(query_condition)) # nosec
|
""".format(query_condition), as_dict=1) # nosec
|
||||||
|
|
||||||
if lead:
|
if lead:
|
||||||
last_communication = frappe.get_all('Communication', filters={
|
last_communication = frappe.get_all('Communication', filters={
|
||||||
'reference_doctype': reference_doc.doctype,
|
'reference_doctype': 'Contact',
|
||||||
'reference_name': reference_doc.name,
|
'reference_name': contact,
|
||||||
'sent_or_received': 'Received'
|
'sent_or_received': 'Received'
|
||||||
}, fields=['name', 'content'], limit=1)
|
}, fields=['name', 'content'], limit=1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user