diff --git a/frappe/__init__.py b/frappe/__init__.py
index df05c479f4..9e176e6077 100644
--- a/frappe/__init__.py
+++ b/frappe/__init__.py
@@ -738,6 +738,9 @@ def get_file_json(path):
def read_file(path, raise_not_found=False):
"""Open a file and return its content as Unicode."""
from frappe.utils import cstr
+ if isinstance(path, unicode):
+ path = path.encode("utf-8")
+
if os.path.exists(path):
with open(path, "r") as f:
return cstr(f.read())
diff --git a/frappe/email/doctype/email_alert/email_alert.json b/frappe/email/doctype/email_alert/email_alert.json
index ee431c57b6..d4189a0de5 100644
--- a/frappe/email/doctype/email_alert/email_alert.json
+++ b/frappe/email/doctype/email_alert/email_alert.json
@@ -56,6 +56,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "description": "To add dynamic subject, use jinja tags like\n\n
",
"fieldname": "subject",
"fieldtype": "Data",
"hidden": 0,
@@ -105,7 +106,7 @@
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 1,
- "label": "Send Alert On",
+ "label": "Send Alert On",
"no_copy": 0,
"options": "\nNew\nSave\nSubmit\nCancel\nDays After\nDays Before\nValue Change",
"permlevel": 0,
@@ -411,7 +412,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
- "modified": "2015-10-02 07:38:47.925050",
+ "modified": "2015-10-16 01:35:51.254775",
"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 4b4065791f..2366652de3 100644
--- a/frappe/email/doctype/email_alert/email_alert.py
+++ b/frappe/email/doctype/email_alert/email_alert.py
@@ -94,7 +94,11 @@ def evaluate_alert(doc, alert, event):
if not recipients:
return
- frappe.sendmail(recipients=recipients, subject=alert.subject,
+ subject = alert.subject
+ if "{" in subject:
+ subject = frappe.render_template(alert.subject, {"doc": doc, "alert": alert})
+
+ frappe.sendmail(recipients=recipients, subject=subject,
message= frappe.render_template(alert.message, {"doc": doc, "alert":alert}),
bulk=True, reference_doctype = doc.doctype, reference_name = doc.name,
attachments = [frappe.attach_print(doc.doctype, doc.name)] if alert.attach_print else None)