fix: pass attached_doc to doc

This commit is contained in:
prssanna 2020-05-31 22:43:14 +05:30
parent bc7ffcab21
commit 73d3d1f409
2 changed files with 3 additions and 9 deletions

View file

@ -61,10 +61,6 @@ def enqueue_create_notification(users, doc):
def make_notification_logs(doc, users):
from frappe.social.doctype.energy_point_settings.energy_point_settings import is_energy_point_enabled
attachment = None
if doc.attachment:
attachment = doc.pop('attachment')
for user in users:
if frappe.db.exists('User', user):
if is_notifications_enabled(user):
@ -76,8 +72,6 @@ def make_notification_logs(doc, users):
_doc.for_user = user
_doc.subject = _doc.subject.replace('<div>', '').replace('</div>', '')
if _doc.for_user != _doc.from_user or doc.type == 'Energy Point' or doc.type == 'Alert':
if attachment:
_doc.attached_file = json.dumps(attachment)
_doc.insert(ignore_permissions=True)
def send_notification_email(doc):

View file

@ -127,7 +127,7 @@ def get_context(context):
self.send_a_slack_msg(doc, context)
if self.channel == 'System Notification' or self.send_system_notification:
self.create_drodown_notification(doc, context)
self.create_system_notification(doc, context)
if self.set_property_after_alert:
allow_update = True
@ -147,7 +147,7 @@ def get_context(context):
except Exception:
frappe.log_error(title='Document update failed', message=frappe.get_traceback())
def create_drodown_notification(self, doc, context):
def create_system_notification(self, doc, context):
subject = self.subject
if "{" in subject:
subject = frappe.render_template(self.subject, context)
@ -162,7 +162,7 @@ def get_context(context):
'document_name': doc.name,
'subject': subject,
'email_content': frappe.render_template(self.message, context),
'attachment': attachments and attachments[0]
'attached_file': attachments and json.dumps(attachments[0])
}
enqueue_create_notification(users, notification_doc)