feat(CRM): Email Group Option In Email Campaign (#22731)

* new parent updating logic, made requested changes

* feat: adding Email Group option in Email Campaign

* fix: inv commas
This commit is contained in:
Abhishek Balam 2020-07-23 19:07:11 +05:30 committed by GitHub
parent d05a98517d
commit cb45836cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,5 @@
{
"actions": [],
"autoname": "format:MAIL-CAMP-{YYYY}-{#####}",
"creation": "2019-06-30 16:05:30.015615",
"doctype": "DocType",
@ -52,7 +53,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Email Campaign For ",
"options": "\nLead\nContact",
"options": "\nLead\nContact\nEmail Group",
"reqd": 1
},
{
@ -70,7 +71,8 @@
"options": "User"
}
],
"modified": "2019-11-11 17:18:47.342839",
"links": [],
"modified": "2020-07-15 12:43:25.548682",
"modified_by": "Administrator",
"module": "CRM",
"name": "Email Campaign",

View File

@ -70,10 +70,15 @@ def send_email_to_leads_or_contacts():
send_mail(entry, email_campaign)
def send_mail(entry, email_campaign):
recipient = frappe.db.get_value(email_campaign.email_campaign_for, email_campaign.get("recipient"), 'email_id')
recipient_list = []
if email_campaign.email_campaign_for == "Email Group":
for member in frappe.db.get_list("Email Group Member", filters={"email_group": email_campaign.get("recipient")}, fields=["email"]):
recipient_list.append(member['email'])
else:
recipient_list.append(frappe.db.get_value(email_campaign.email_campaign_for, email_campaign.get("recipient"), "email_id"))
email_template = frappe.get_doc("Email Template", entry.get("email_template"))
sender = frappe.db.get_value("User", email_campaign.get("sender"), 'email')
sender = frappe.db.get_value("User", email_campaign.get("sender"), "email")
context = {"doc": frappe.get_doc(email_campaign.email_campaign_for, email_campaign.recipient)}
# send mail and link communication to document
comm = make(
@ -82,7 +87,7 @@ def send_mail(entry, email_campaign):
subject = frappe.render_template(email_template.get("subject"), context),
content = frappe.render_template(email_template.get("response"), context),
sender = sender,
recipients = recipient,
recipients = recipient_list,
communication_medium = "Email",
sent_or_received = "Sent",
send_email = True,