Skip to content

Commit

Permalink
Merge pull request #411 from shariquerik/show-lead-whatsapp-chat-in-deal
Browse files Browse the repository at this point in the history
fix: move lead whatsapp chat to deal on convertion
  • Loading branch information
shariquerik authored Oct 12, 2024
2 parents 8aff67d + 6658609 commit 068edf8
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion crm/api/whatsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,41 @@ def is_whatsapp_installed():
def get_whatsapp_messages(reference_doctype, reference_name):
if not frappe.db.exists("DocType", "WhatsApp Message"):
return []
messages = frappe.get_all(
messages = []

if reference_doctype == 'CRM Deal':
lead = frappe.db.get_value(reference_doctype, reference_name, 'lead')
if lead:
messages = frappe.get_all(
"WhatsApp Message",
filters={
"reference_doctype": "CRM Lead",
"reference_name": lead,
},
fields=[
"name",
"type",
"to",
"from",
"content_type",
"message_type",
"attach",
"template",
"use_template",
"message_id",
"is_reply",
"reply_to_message_id",
"creation",
"message",
"status",
"reference_doctype",
"reference_name",
"template_parameters",
"template_header_parameters",
],
)

messages += frappe.get_all(
"WhatsApp Message",
filters={
"reference_doctype": reference_doctype,
Expand Down

0 comments on commit 068edf8

Please sign in to comment.