From cb1f3614612a7005a75f54228aeaa1a4f99907ea Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Jan 2012 13:46:46 +0530 Subject: [PATCH] Fix: Notify via email on new post on my company page --- erpnext/home/page/my_company/my_company.py | 17 +++++++++++++---- .../notification_control.py | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py index dfeb30feba..c239162797 100644 --- a/erpnext/home/page/my_company/my_company.py +++ b/erpnext/home/page/my_company/my_company.py @@ -119,17 +119,26 @@ def post_comment(arg): else: fn = webnotes.user.name - from webnotes.utils.email_lib import sendmail - from setup.doctype.notification_control.notification_control import get_formatted_message - message = '''A new comment has been posted on your page by %s: Comment: %s To answer, please login to your erpnext account! + + https://signin.erpnext.com ''' % (fn, arg['comment']) - sendmail([arg['uid']], webnotes.user.name, get_formatted_message('New Comment', message), fn + ' has posted a new comment') + from webnotes.model.code import get_obj + note = get_obj('Notification Control') + email_msg = note.prepare_message({ + 'type': 'New Comment', + 'message': message + }) + + sender = webnotes.user.name!='Administrator' and webnotes.user.name or 'support+admin_post@erpnext.com' + + from webnotes.utils.email_lib import sendmail + sendmail([arg['uid']], sender, email_msg, fn + ' has posted a new comment') # # update read messages diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py index 216c46b180..ae37cbdbef 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.py +++ b/erpnext/setup/doctype/notification_control/notification_control.py @@ -55,9 +55,9 @@ class DocType: """ Prepares message body """ - if args.get('type') and args.get('doctype'): + if args.get('type'): msg_dict = {} - msg_dict['message'] = self.get_message(args.get('type')) + msg_dict['message'] = args.get('message') or self.get_message(args.get('type')) msg_dict['company'] = Document('Control Panel', 'Control Panel').company_name msg_dict['salutation'] = "Hi" + (args.get('contact_name') and (" " + args.get('contact_name')) or "") msg_dict['send_from'] = webnotes.conn.sql("""\