dash: added Email Campaign to CRM dashboard
This commit is contained in:
parent
bbb22ad082
commit
b54459e588
@ -141,6 +141,11 @@ def get_data():
|
||||
"name": "Campaign",
|
||||
"description": _("Sales campaigns."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Email Campaign",
|
||||
"description": _("Sends Mails to lead or contact based on a Campaign schedule"),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "SMS Center",
|
||||
|
@ -15,6 +15,7 @@ class EmailCampaign(Document):
|
||||
#checking if email is set for lead. Not checking for contact as email is a mandatory field for contact.
|
||||
if self.email_campaign_for == "Lead":
|
||||
self.validate_lead()
|
||||
self.validate_email_campaign_already_exists()
|
||||
self.update_status()
|
||||
|
||||
def validate_dates(self):
|
||||
@ -40,6 +41,10 @@ class EmailCampaign(Document):
|
||||
if not lead_email_id:
|
||||
frappe.throw(_("Please set an email id for lead communication"))
|
||||
|
||||
def validate_email_campaign_already_exists(self):
|
||||
if frappe.db.get_value("Email Campaign", {"campaign_name": self.campaign_name, "recipient": self.recipient, "status": "Active"}):
|
||||
frappe.throw(_("The Campaign '{0}' already exists for the {1} '{2}'").format(self.campaign_name, self.email_campaign_for, self.recipient))
|
||||
|
||||
def update_status(self):
|
||||
start_date = getdate(self.start_date)
|
||||
end_date = getdate(self.end_date)
|
||||
@ -52,7 +57,7 @@ class EmailCampaign(Document):
|
||||
self.status = "Completed"
|
||||
|
||||
#called through hooks to send campaign mails to leads
|
||||
def send_email_to_leads():
|
||||
def send_email_to_leads_or_contacts():
|
||||
email_campaigns = frappe.get_all("Email Campaign", filters = { 'status': ('not in', ['Unsubscribed', 'Completed', 'Scheduled']) })
|
||||
for camp in email_campaigns:
|
||||
email_campaign = frappe.get_doc("Email Campaign", camp.name)
|
||||
@ -81,6 +86,7 @@ def send_mail(entry, email_campaign):
|
||||
send_email = True,
|
||||
email_template = email_template.name
|
||||
)
|
||||
return comm
|
||||
|
||||
#called from hooks on doc_event Email Unsubscribe
|
||||
def unsubscribe_recipient(unsubscribe, method):
|
||||
|
@ -275,7 +275,7 @@ scheduler_events = {
|
||||
"erpnext.projects.doctype.project.project.send_project_status_email_to_users",
|
||||
"erpnext.quality_management.doctype.quality_review.quality_review.review",
|
||||
"erpnext.support.doctype.service_level_agreement.service_level_agreement.check_agreement_status",
|
||||
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads",
|
||||
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
|
||||
"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status"
|
||||
],
|
||||
"daily_long": [
|
||||
|
0
erpnext/www/lms/macros/__init__.py
Normal file
0
erpnext/www/lms/macros/__init__.py
Normal file
Loading…
x
Reference in New Issue
Block a user