Merge pull request #15821 from ankush/missing_email

fix: communication missing from form timeline
This commit is contained in:
mergify[bot] 2022-02-01 08:30:04 +00:00 committed by GitHub
commit e43cf12941
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 6 deletions

View file

@ -42,7 +42,8 @@ def getdoc(doctype, name, user=None):
# add file list
doc.add_viewed()
get_docinfo(doc)
frappe.response["docinfo"] = get_docinfo(doc)
except Exception:
frappe.errprint(frappe.utils.get_traceback())
@ -91,8 +92,8 @@ def get_docinfo(doc=None, doctype=None, name=None):
raise frappe.PermissionError
all_communications = _get_communications(doc.doctype, doc.name)
automated_messages = filter(lambda x: x['communication_type'] == 'Automated Message', all_communications)
communications_except_auto_messages = filter(lambda x: x['communication_type'] != 'Automated Message', all_communications)
automated_messages = [msg for msg in all_communications if msg['communication_type'] == 'Automated Message']
communications_except_auto_messages = [msg for msg in all_communications if msg['communication_type'] != 'Automated Message']
docinfo = frappe._dict(user_info = {})
@ -118,7 +119,7 @@ def get_docinfo(doc=None, doctype=None, name=None):
update_user_info(docinfo)
frappe.response["docinfo"] = docinfo
return docinfo
def add_comments(doc, docinfo):
# divide comments into separate lists

View file

@ -1,9 +1,10 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import frappe, unittest
from frappe.desk.form.load import getdoctype, getdoc
from frappe.desk.form.load import getdoctype, getdoc, get_docinfo
from frappe.core.page.permission_manager.permission_manager import update, reset, add
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
from frappe.utils.file_manager import save_file
test_dependencies = ['Blog Category', 'Blogger']
@ -141,9 +142,52 @@ class TestFormLoad(unittest.TestCase):
contact.delete()
def test_get_doc_info(self):
note = frappe.new_doc("Note")
note.content = "some content"
note.title = frappe.generate_hash(length=20)
note.insert()
note.content = "new content"
# trigger a version
note.save(ignore_version=False)
note.add_comment(text="test")
note.add_tag("test_tag")
note.add_tag("more_tag")
# empty attachment
save_file("test_file", b"", note.doctype, note.name, decode=True)
frappe.get_doc({
"doctype": "Communication",
"communication_type": "Communication",
"content": "test email",
"reference_doctype": note.doctype,
"reference_name": note.name,
}).insert()
docinfo = get_docinfo(note)
self.assertEqual(len(docinfo.comments), 1)
self.assertIn("test", docinfo.comments[0].content)
self.assertGreaterEqual(len(docinfo.versions), 2)
self.assertEqual(set(docinfo.tags.split(",")), {"more_tag", "test_tag"})
self.assertEqual(len(docinfo.attachments), 1)
self.assertIn("test_file", docinfo.attachments[0].file_name)
self.assertEqual(len(docinfo.communications), 1)
self.assertIn("email", docinfo.communications[0].content)
note.delete()
def get_blog(blog_name):
frappe.response.docs = []
getdoc('Blog Post', blog_name)
doc = frappe.response.docs[0]
return doc
return doc