webnotes/erpnext#869 newsletter to send to employees

This commit is contained in:
Akhilesh Darjee 2014-02-03 19:28:36 +05:30
parent 81578d2e77
commit f1c3537924
2 changed files with 10 additions and 2 deletions

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-07 09:04:18",
"docstatus": 0,
"modified": "2014-01-20 17:48:40",
"modified": "2014-02-03 18:06:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -457,6 +457,12 @@
"fieldtype": "Data",
"label": "Personal Email"
},
{
"doctype": "DocField",
"fieldname": "unsubscribed",
"fieldtype": "Check",
"label": "Unsubscribed"
},
{
"doctype": "DocField",
"fieldname": "emergency_contact_details",

View File

@ -70,6 +70,8 @@ class DocType():
elif self.doc.send_to_type=="Employee":
self.send_to_doctype = "Employee"
self.email_field = "company_email"
return webnotes.conn.sql_list("""select
if(ifnull(company_email, '')!='', company_email, personal_email) as email_id
from `tabEmployee` where status='Active'""")
@ -94,7 +96,7 @@ class DocType():
send(recipients = self.recipients, sender = sender,
subject = self.doc.subject, message = self.doc.message,
doctype = self.send_to_doctype, email_field = "email_id",
doctype = self.send_to_doctype, email_field = self.email_field or "email_id",
ref_doctype = self.doc.doctype, ref_docname = self.doc.name)
if not webnotes.flags.in_test: