From 487ff091c8bf76cd3f362d0b78e639ac7c215f8b Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 27 Jan 2022 18:31:01 +0530 Subject: [PATCH] refactor(minor): email.make API * Avoid double save if possible - seemed like it was added mistakenly, didnt find enough evidence for it's addition * Avoid json.loads breaking if "" was passed for attachments --- frappe/core/doctype/communication/email.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frappe/core/doctype/communication/email.py b/frappe/core/doctype/communication/email.py index 1346054aaf..46ef7bf5d2 100755 --- a/frappe/core/doctype/communication/email.py +++ b/frappe/core/doctype/communication/email.py @@ -76,16 +76,13 @@ def make(doctype=None, name=None, content=None, subject=None, sent_or_received = "message_id":get_message_id().strip(" <>"), "read_receipt":read_receipt, "has_attachment": 1 if attachments else 0, - "communication_type": communication_type + "communication_type": communication_type, }).insert(ignore_permissions=True) - comm.save(ignore_permissions=True) - - if isinstance(attachments, str): - attachments = json.loads(attachments) - # if not committed, delayed task doesn't find the communication if attachments: + if isinstance(attachments, str): + attachments = json.loads(attachments) add_attachments(comm.name, attachments) if cint(send_email):