diff --git a/frappe/email/doctype/email_account/email_account.json b/frappe/email/doctype/email_account/email_account.json
index a6879b2af3..3e0e666bc0 100644
--- a/frappe/email/doctype/email_account/email_account.json
+++ b/frappe/email/doctype/email_account/email_account.json
@@ -388,6 +388,7 @@
{
"allow_on_submit": 0,
"depends_on": "enable_auto_reply",
+ "description": "ProTip: Add Reference: {{ reference_doctype }} {{ reference_name }} to send document reference",
"fieldname": "auto_reply_message",
"fieldtype": "Text Editor",
"hidden": 0,
@@ -428,7 +429,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
- "modified": "2015-06-11 00:16:24.026081",
+ "modified": "2015-07-16 10:11:06.466258",
"modified_by": "Administrator",
"module": "Email",
"name": "Email Account",
diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py
index ef2200045f..9bb2bc5742 100644
--- a/frappe/email/doctype/email_account/email_account.py
+++ b/frappe/email/doctype/email_account/email_account.py
@@ -7,6 +7,7 @@ from frappe import _
from frappe.model.document import Document
from frappe.utils import validate_email_add, cint, get_datetime, DATE_FORMAT, strip
from frappe.utils.user import is_system_user
+from frappe.utils.jinja import render_template
from frappe.email.smtp import SMTPServer
from frappe.email.receive import POP3Server, Email
from poplib import error_proto
@@ -233,13 +234,16 @@ class EmailAccount(Document):
try:
parent.insert(ignore_permissions=True)
- except frappe.DuplicateEntryError:
- # try and find matching parent
- parent_name = frappe.db.get_value(self.append_to, {sender_field: email.from_email})
- if parent_name:
- parent.name = parent_name
+ except frappe.NameError, e:
+ if e.args and e.args[0]==self.append_to:
+ # try and find matching parent
+ parent_name = frappe.db.get_value(self.append_to, {sender_field: email.from_email})
+ if parent_name:
+ parent.name = parent_name
+ else:
+ parent = None
else:
- parent = None
+ raise
communication.is_first = True
@@ -249,14 +253,14 @@ class EmailAccount(Document):
def send_auto_reply(self, communication, email):
"""Send auto reply if set."""
- if self.auto_reply_message:
+ if self.enable_auto_reply:
communication.set_incoming_outgoing_accounts()
frappe.sendmail(recipients = [email.from_email],
sender = self.email_id,
reply_to = communication.incoming_email_account,
subject = _("Re: ") + communication.subject,
- content = self.auto_reply_message or \
+ content = render_template(self.auto_reply_message or "", communication.as_dict()) or \
frappe.get_template("templates/emails/auto_reply.html").render(communication.as_dict()),
reference_doctype = communication.reference_doctype,
reference_name = communication.reference_name,
diff --git a/frappe/public/js/frappe/form/workflow.js b/frappe/public/js/frappe/form/workflow.js
index 1c258eca4c..13947aebb9 100644
--- a/frappe/public/js/frappe/form/workflow.js
+++ b/frappe/public/js/frappe/form/workflow.js
@@ -67,6 +67,11 @@ frappe.ui.form.States = Class.extend({
this.frm.page.clear_actions_menu();
+ // if the loaded doc is dirty, don't show workflow buttons
+ if (this.frm.doc.__unsaved===1) {
+ return;
+ }
+
$.each(frappe.workflow.get_transitions(this.frm.doctype, state), function(i, d) {
if(in_list(user_roles, d.allowed)) {
added = true;
@@ -89,7 +94,6 @@ frappe.ui.form.States = Class.extend({
// revert state on error
var on_error = function() {
- console.log("here", doc_before_action);
// reset in locals
frappe.model.add_to_locals(doc_before_action);
me.frm.refresh();
diff --git a/frappe/templates/emails/auto_reply.html b/frappe/templates/emails/auto_reply.html
index 394b608e6a..2181694cff 100644
--- a/frappe/templates/emails/auto_reply.html
+++ b/frappe/templates/emails/auto_reply.html
@@ -1,5 +1,6 @@
{{ _("Your query has been received. We will back reply shortly. If you have any additional information, please reply to this mail.") }}
+{{ _("Your query has been received. We will reply back shortly. If you have any additional information, please reply to this mail.") }}
+{{ _("Reference: {0} {1}").format(reference_doctype, reference_name) }}
{{ _("This is an automatically generated reply") }}