diff --git a/frappe/desk/doctype/notification_log/notification_log.json b/frappe/desk/doctype/notification_log/notification_log.json
index 86213da242..e8225956b8 100644
--- a/frappe/desk/doctype/notification_log/notification_log.json
+++ b/frappe/desk/doctype/notification_log/notification_log.json
@@ -9,7 +9,6 @@
"for_user",
"type",
"email_content",
- "column_break_4",
"document_type",
"read",
"document_name",
@@ -26,6 +25,7 @@
{
"fieldname": "for_user",
"fieldtype": "Link",
+ "hidden": 1,
"label": "For User",
"options": "User",
"read_only": 1
@@ -33,6 +33,7 @@
{
"fieldname": "type",
"fieldtype": "Select",
+ "hidden": 1,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Type",
@@ -42,17 +43,14 @@
},
{
"fieldname": "email_content",
- "fieldtype": "Text",
- "label": "Email Content",
+ "fieldtype": "Text Editor",
+ "label": "Message",
"read_only": 1
},
- {
- "fieldname": "column_break_4",
- "fieldtype": "Column Break"
- },
{
"fieldname": "document_type",
"fieldtype": "Link",
+ "hidden": 1,
"label": "Document Type",
"options": "DocType",
"read_only": 1,
@@ -61,13 +59,14 @@
{
"fieldname": "document_name",
"fieldtype": "Data",
- "label": "Document Name",
+ "label": "Document Link",
"read_only": 1,
"search_index": 1
},
{
"fieldname": "from_user",
"fieldtype": "Link",
+ "hidden": 1,
"label": "From User",
"options": "User",
"read_only": 1,
@@ -84,8 +83,8 @@
],
"in_create": 1,
"links": [],
- "modified": "2020-05-08 15:16:36.365285",
- "modified_by": "Administrator",
+ "modified": "2020-05-11 15:18:20.893718",
+ "modified_by": "umair@erpnext.com",
"module": "Desk",
"name": "Notification Log",
"owner": "Administrator",
diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py
index 0112e68b1d..2db552e7de 100644
--- a/frappe/desk/doctype/notification_log/notification_log.py
+++ b/frappe/desk/doctype/notification_log/notification_log.py
@@ -65,11 +65,26 @@ def make_notification_logs(doc, users):
return
_doc = frappe.new_doc('Notification Log')
+
+ attachments = None
+ if doc.attachments:
+ attachments = doc.pop('attachments')
+
_doc.update(doc)
_doc.for_user = user
_doc.subject = _doc.subject.replace('
', '').replace('
', '')
if _doc.for_user != _doc.from_user or doc.type == 'Energy Point' or doc.type == 'Alert':
_doc.insert(ignore_permissions=True)
+ if attachments:
+ attach_file_to_doc(attachments, _doc.name)
+
+
+def attach_file_to_doc(attachments, docname):
+ from frappe.utils.file_manager import save_file
+ for attachment in attachments:
+ attachment.pop("print_format_attachment", None)
+ print_format_file = frappe._dict(frappe.attach_print(**attachment))
+ save_file(print_format_file.fname, print_format_file.fcontent, 'Notification Log', docname)
def send_notification_email(doc):
diff --git a/frappe/email/doctype/notification/notification.py b/frappe/email/doctype/notification/notification.py
index cac4bbddc2..6d74e499d9 100644
--- a/frappe/email/doctype/notification/notification.py
+++ b/frappe/email/doctype/notification/notification.py
@@ -151,8 +151,8 @@ def get_context(context):
subject = self.subject
if "{" in subject:
subject = frappe.render_template(self.subject, context)
- subject = '[Alert] ' + subject
+ attachments = self.get_attachment(doc)
recipients, cc, bcc = self.get_list_of_recipients(doc, context)
users = recipients + cc + bcc
@@ -161,6 +161,8 @@ def get_context(context):
'document_type': doc.doctype,
'document_name': doc.name,
'subject': subject,
+ 'email_content': frappe.render_template(self.message, context),
+ 'attachments': attachments
}
enqueue_create_notification(recipients, notification_doc)
diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js
index 2420d6772e..14d3b9bbd0 100644
--- a/frappe/public/js/frappe/ui/notifications/notifications.js
+++ b/frappe/public/js/frappe/ui/notifications/notifications.js
@@ -304,10 +304,7 @@ frappe.ui.Notifications = class Notifications {
}
get_dropdown_item_html(field) {
- let doc_link = frappe.utils.get_form_link(
- field.document_type,
- field.document_name
- );
+ let doc_link = this.get_item_link(field);
let read_class = field.read ? '' : 'unread';
let mark_read_action = field.read ? '': 'data-action="mark_as_read"';
let message = field.subject;
@@ -336,6 +333,15 @@ frappe.ui.Notifications = class Notifications {
return item_html;
}
+ get_item_link(field) {
+ const link_doctype = field.type == 'Alert'? 'Notification Log': field.document_type;
+ const link_docname = field.type == 'Alert'? field.name: field.document_name;
+ return frappe.utils.get_form_link(
+ link_doctype,
+ link_docname
+ );
+ }
+
render_dropdown_headers() {
this.categories = [
{