Explorar el Código

Merge pull request #15821 from ankush/missing_email

fix: communication missing from form timeline
version-14
mergify[bot] hace 3 años
committed by GitHub
padre
commit
e43cf12941
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 2 ficheros con 51 adiciones y 6 borrados
  1. +5
    -4
      frappe/desk/form/load.py
  2. +46
    -2
      frappe/tests/test_form_load.py

+ 5
- 4
frappe/desk/form/load.py Ver fichero

@@ -42,7 +42,8 @@ def getdoc(doctype, name, user=None):


# add file list # add file list
doc.add_viewed() doc.add_viewed()
get_docinfo(doc)
frappe.response["docinfo"] = get_docinfo(doc)



except Exception: except Exception:
frappe.errprint(frappe.utils.get_traceback()) frappe.errprint(frappe.utils.get_traceback())
@@ -91,8 +92,8 @@ def get_docinfo(doc=None, doctype=None, name=None):
raise frappe.PermissionError raise frappe.PermissionError


all_communications = _get_communications(doc.doctype, doc.name) 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 = {}) docinfo = frappe._dict(user_info = {})


@@ -118,7 +119,7 @@ def get_docinfo(doc=None, doctype=None, name=None):


update_user_info(docinfo) update_user_info(docinfo)


frappe.response["docinfo"] = docinfo
return docinfo


def add_comments(doc, docinfo): def add_comments(doc, docinfo):
# divide comments into separate lists # divide comments into separate lists


+ 46
- 2
frappe/tests/test_form_load.py Ver fichero

@@ -1,9 +1,10 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE # License: MIT. See LICENSE
import frappe, unittest 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.core.page.permission_manager.permission_manager import update, reset, add
from frappe.custom.doctype.property_setter.property_setter import make_property_setter 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'] test_dependencies = ['Blog Category', 'Blogger']


@@ -141,9 +142,52 @@ class TestFormLoad(unittest.TestCase):


contact.delete() 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): def get_blog(blog_name):
frappe.response.docs = [] frappe.response.docs = []
getdoc('Blog Post', blog_name) getdoc('Blog Post', blog_name)
doc = frappe.response.docs[0] doc = frappe.response.docs[0]
return doc
return doc

Cargando…
Cancelar
Guardar