Merge pull request #6035 from rohitwaghchaure/email_notify_not_working

On assignment notification is not sent to the assigned user
This commit is contained in:
Faris Ansari 2018-09-07 12:45:01 +05:30 committed by GitHub
commit 030d6d89f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -163,4 +163,30 @@ def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE',
'notify': notify
}
arg["parenttype"] = "Assignment"
if arg and arg.get("notify"):
_notify(arg)
def _notify(args):
from frappe.utils import get_fullname, get_url
args = frappe._dict(args)
contact = args.contact
txt = args.txt
try:
if not isinstance(contact, list):
contact = [frappe.db.get_value("User", contact, "email") or contact]
frappe.sendmail(\
recipients=contact,
sender= frappe.db.get_value("User", frappe.session.user, "email"),
subject=_("New message from {0}").format(get_fullname(frappe.session.user)),
template="new_message",
args={
"from": get_fullname(frappe.session.user),
"message": txt,
"link": get_url()
},
header=[_('New Message'), 'orange'])
except frappe.OutgoingEmailError:
pass