Added override for email campaign sending to send emails at 08:15AM instead of midnight
This commit is contained in:
1
rangeldigital/utilities/lead/__init__.py
Normal file
1
rangeldigital/utilities/lead/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__version__ = "0.0.1"
|
||||
Binary file not shown.
Binary file not shown.
31
rangeldigital/utilities/lead/lead_api.py
Normal file
31
rangeldigital/utilities/lead/lead_api.py
Normal file
@ -0,0 +1,31 @@
|
||||
import frappe
|
||||
from frappe.utils import today
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_lead_to_campaign(lead_name, campaign_name, start_date=None):
|
||||
if not frappe.db.exists("Lead", lead_name):
|
||||
frappe.throw("Lead does not exist")
|
||||
|
||||
# Check if there's already a scheduled/in-progress campaign for this Lead with same name
|
||||
existing = frappe.db.exists("Email Campaign", {
|
||||
"recipient": lead_name,
|
||||
"campaign_name": campaign_name,
|
||||
"email_campaign_for": "Lead",
|
||||
"status": ["in", ["Scheduled", "In Progress"]]
|
||||
})
|
||||
|
||||
if existing:
|
||||
frappe.throw("This Lead is already part of an Email Campaign with this name.")
|
||||
|
||||
doc = frappe.new_doc("Email Campaign")
|
||||
doc.update({
|
||||
"campaign_name": campaign_name,
|
||||
"email_campaign_for": "Lead",
|
||||
"recipient": lead_name,
|
||||
"start_date": start_date or today(),
|
||||
"sender": frappe.session.user # or replace with a specific default sender
|
||||
})
|
||||
doc.insert(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
|
||||
return {"status": "success", "message": "Email Campaign created"}
|
||||
Reference in New Issue
Block a user