diff --git a/frappe/email/doctype/email_alert/email_alert.json b/frappe/email/doctype/email_alert/email_alert.json index 8e5d0d0281..b329c4ccae 100644 --- a/frappe/email/doctype/email_alert/email_alert.json +++ b/frappe/email/doctype/email_alert/email_alert.json @@ -25,6 +25,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -47,6 +48,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -70,6 +72,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -93,6 +96,7 @@ "options": "DocType", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -116,6 +120,7 @@ "options": "\nNew\nSave\nSubmit\nCancel\nDays After\nDays Before\nValue Change", "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -140,6 +145,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -165,6 +171,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -189,6 +196,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -213,6 +221,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -234,6 +243,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -256,6 +266,7 @@ "options": "
Condition Examples:
\ndoc.status==\"Open\"\ndoc.due_date==nowdate()\ndoc.total > 40000\n\n
Hints:
\n\nOrder Overdue
\n\nTransaction {{ doc.name }} has exceeded Due Date. Please take necessary action.
\n\nDetails
\n\n
\n<h3>Order Overdue</h3>\n\n<p>Transaction {{ doc.name }} has exceeded Due Date. Please take necessary action.</p>\n\n<!-- show last comment -->\n{% if comments %}\nLast comment: {{ comments[-1].comment }} by {{ comments[-1].by }}\n{% endif %}\n\n<h4>Details</h4>\n\n<ul>\n<li>Customer: {{ doc.customer }}\n<li>Amount: {{ doc.total_amount }}\n</ul>\n",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -414,6 +431,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -425,13 +443,15 @@
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-envelope",
+ "idx": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2015-11-16 06:29:46.014034",
+ "menu_index": 0,
+ "modified": "2015-11-26 02:14:59.637519",
"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 2366652de3..5da08920c8 100644
--- a/frappe/email/doctype/email_alert/email_alert.py
+++ b/frappe/email/doctype/email_alert/email_alert.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+import json
from frappe import _
from frappe.model.document import Document
from frappe.utils import validate_email_add, nowdate
@@ -95,10 +96,21 @@ def evaluate_alert(doc, alert, event):
return
subject = alert.subject
+
+ if event != "Value Change" and not doc.is_new():
+ # reload the doc for the latest values & comments,
+ # except for validate type event.
+ doc = frappe.get_doc(doc.doctype, doc.name)
+
+ context = {"doc": doc, "alert": alert, "comments": None}
+
+ if doc.get("_comments"):
+ context["comments"] = json.loads(doc.get("_comments"))
+
if "{" in subject:
- subject = frappe.render_template(alert.subject, {"doc": doc, "alert": alert})
+ subject = frappe.render_template(alert.subject, context)
frappe.sendmail(recipients=recipients, subject=subject,
- message= frappe.render_template(alert.message, {"doc": doc, "alert":alert}),
+ message= frappe.render_template(alert.message, context),
bulk=True, reference_doctype = doc.doctype, reference_name = doc.name,
attachments = [frappe.attach_print(doc.doctype, doc.name)] if alert.attach_print else None)