Merge pull request #1202 from anandpdoshi/anand-july-16
Fixes in workflow actions visibility, duplicate entry error in email account pulling and sending reference in email auto-reply
This commit is contained in:
commit
ccbf8e7112
4 changed files with 21 additions and 11 deletions
|
|
@ -388,6 +388,7 @@
|
|||
{
|
||||
"allow_on_submit": 0,
|
||||
"depends_on": "enable_auto_reply",
|
||||
"description": "ProTip: Add <code>Reference: {{ reference_doctype }} {{ reference_name }}</code> 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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<h3>{{ _("Thank you for your email") }}</h3>
|
||||
<p>{{ _("Your query has been received. We will back reply shortly. If you have any additional information, please reply to this mail.") }}</p>
|
||||
<p>{{ _("Your query has been received. We will reply back shortly. If you have any additional information, please reply to this mail.") }}</p>
|
||||
<p>{{ _("Reference: {0} {1}").format(reference_doctype, reference_name) }}</p>
|
||||
<p style="font-size: 80%; color: #888">
|
||||
{{ _("This is an automatically generated reply") }}
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue