diff --git a/frappe/email/doctype/email_alert/email_alert.js b/frappe/email/doctype/email_alert/email_alert.js index 3f7423bc1b..a901b257cb 100755 --- a/frappe/email/doctype/email_alert/email_alert.js +++ b/frappe/email/doctype/email_alert/email_alert.js @@ -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 diff --git a/frappe/email/doctype/email_alert/email_alert.json b/frappe/email/doctype/email_alert/email_alert.json index fd3763cd14..860bfbd46d 100755 --- a/frappe/email/doctype/email_alert/email_alert.json +++ b/frappe/email/doctype/email_alert/email_alert.json @@ -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", diff --git a/frappe/email/doctype/email_alert/email_alert.py b/frappe/email/doctype/email_alert/email_alert.py index cfd081d7ae..ac0ef21536 100755 --- a/frappe/email/doctype/email_alert/email_alert.py +++ b/frappe/email/doctype/email_alert/email_alert.py @@ -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,