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