Deleted Previous Chat Reference for Leave Application Approval (#12482)

* deleted previous chat reference

* txt to messge

* removed comment
This commit is contained in:
Achilles Rasquinha 2018-01-15 14:12:41 +05:30 committed by Nabin Hait
parent 58dfc0782f
commit b6365b729e

View File

@ -284,10 +284,42 @@ class LeaveApplication(Document):
def notify(self, args):
args = frappe._dict(args)
from frappe.desk.page.chat.chat import post
post(**{"txt": args.message, "contact": args.message_to, "subject": args.subject,
"notify": cint(self.follow_via_email)})
# args -> message, message_to, subject
d = frappe.new_doc('Communication')
d.communication_type = 'Notification'
d.subject = args.subject
d.content = args.message
d.reference_doctype = 'User'
d.reference_name = args.message_to
d.sender = frappe.session.user
d.insert(ignore_permissions = True)
if cint(self.follow_via_email):
contact = args.message_to
if not isinstance(contact, list):
contact = [frappe.get_doc('User', contact).email or contact]
sender = dict()
sender['email'] = frappe.get_doc('User', frappe.session.user).email
sender['full_name'] = frappe.utils.get_fullname(sender['email'])
try:
frappe.sendmail(recipients = contact,
sender = sender['email'],
subject = args.subject or _("New Message from {sender}").format(sender = sender['full_name']),
template = "new_message",
args = {
"from": sender['full_name'],
"message": args.message,
"link": frappe.utils.get_url()
},
header = [_('New Message'), 'orange']
)
except frappe.OutgoingEmailError:
# Arrey!
pass
@frappe.whitelist()
def get_approvers(doctype, txt, searchfield, start, page_len, filters):