From a0ba6dd7a18e0df82423e352bb08c54af97f67af Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 30 Jan 2024 01:08:48 +0530 Subject: [PATCH] fix: added reference doctype and name in notification doctype --- crm/api/comment.py | 6 +++--- crm/api/notifications.py | 11 +++++------ .../crm_notification/crm_notification.json | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/crm/api/comment.py b/crm/api/comment.py index 6797da98..8f2df3f2 100644 --- a/crm/api/comment.py +++ b/crm/api/comment.py @@ -22,10 +22,10 @@ def notify_mentions(doc): type="Mention", message=doc.content, comment=doc.name, + reference_doctype=doc.reference_doctype, + reference_name=doc.reference_name, ) - # Why mention oneself? - # if values.from_user == values.to_user: - # continue + if frappe.db.exists("CRM Notification", values): return frappe.get_doc(values).insert() diff --git a/crm/api/notifications.py b/crm/api/notifications.py index b20b75bf..bdbe9118 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -18,9 +18,6 @@ def get_notifications(): _notifications = [] for notification in notifications: - reference_doc = frappe.get_value( - "Comment", notification.comment, ["reference_doctype", "reference_name"] - ) _notifications.append( { "creation": notification.creation, @@ -35,10 +32,12 @@ def get_notifications(): "read": notification.read, "comment": notification.comment, "reference_doctype": "deal" - if reference_doc[0] == "CRM Deal" + if notification.reference_doctype == "CRM Deal" else "lead", - "reference_name": reference_doc[1], - "route_name": "Deal" if reference_doc[0] == "CRM Deal" else "Lead", + "reference_name": notification.reference_name, + "route_name": "Deal" + if notification.reference_doctype == "CRM Deal" + else "Lead", } ) diff --git a/crm/fcrm/doctype/crm_notification/crm_notification.json b/crm/fcrm/doctype/crm_notification/crm_notification.json index 112d52f9..7b9cee2e 100644 --- a/crm/fcrm/doctype/crm_notification/crm_notification.json +++ b/crm/fcrm/doctype/crm_notification/crm_notification.json @@ -7,6 +7,8 @@ "field_order": [ "from_user", "type", + "reference_doctype", + "reference_name", "column_break_dduu", "to_user", "comment", @@ -62,11 +64,23 @@ "fieldname": "message", "fieldtype": "HTML Editor", "label": "Message" + }, + { + "fieldname": "reference_name", + "fieldtype": "Dynamic Link", + "label": "Reference Doc", + "options": "reference_doctype" + }, + { + "fieldname": "reference_doctype", + "fieldtype": "Link", + "label": "Reference Doctype", + "options": "DocType" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-29 20:03:40.102839", + "modified": "2024-01-30 01:04:27.946030", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Notification",