Added outgoing sender in email alert (#5892)

* Added outgoing sender in email alert

* Added semicolon

* Minor fix
This commit is contained in:
FinByz Tech Pvt. Ltd 2018-08-07 14:45:36 +05:30 committed by Rushabh Mehta
parent 62a7214a9b
commit 0f68fec03e
3 changed files with 80 additions and 1 deletions

View file

@ -1,3 +1,13 @@
this.frm.add_fetch('sender', 'email_id', 'sender_email');
this.frm.fields_dict.sender.get_query = function(){
return {
filters: {
'enable_outgoing': 1
}
}
};
frappe.email_alert = {
setup_fieldname_select: function(frm) {
// get the doctype to update fields

View file

@ -379,6 +379,68 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sender",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sender",
"length": 0,
"no_copy": 0,
"options": "Email Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sender_email",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sender Email",
"length": 0,
"no_copy": 0,
"options": "Email",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -871,7 +933,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-09-26 20:10:00.061780",
"modified": "2018-07-30 14:32:02.179599",
"modified_by": "Administrator",
"module": "Email",
"name": "Email Alert",

View file

@ -105,6 +105,7 @@ def get_context(context):
def send(self, doc):
'''Build recipients and send email alert'''
from email.utils import formataddr
def get_attachment(doc):
""" check print settings are attach the pdf """
@ -126,6 +127,7 @@ def get_context(context):
context = get_context(doc)
recipients = []
sender = ""
for recipient in self.recipients:
if recipient.condition:
@ -157,6 +159,10 @@ def get_context(context):
context = {"doc": doc, "alert": self, "comments": None}
if self.sender:
sender = formataddr((self.sender, self.sender_email))
frappe.errprint(sender)
if self.is_standard:
self.load_standard_properties(context)
@ -170,6 +176,7 @@ def get_context(context):
frappe.sendmail(recipients=recipients, subject=subject,
message= frappe.render_template(self.message, context),
sender = sender,
reference_doctype = doc.doctype,
reference_name = doc.name,
attachments = attachments,