From 2b54cd619d52d5cb5c9a05623e7d51c51cce9a6d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 11 May 2017 11:35:57 +0530 Subject: [PATCH] Update only UID of email on communication if existing (#3266) --- .../email/doctype/email_account/email_account.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index dd907468b3..209ee5e55b 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -282,9 +282,9 @@ class EmailAccount(Document): else: frappe.db.commit() - attachments = [d.file_name for d in communication._attachments] - - communication.notify(attachments=attachments, fetched_from_email_account=True) + if communication: + attachments = [d.file_name for d in communication._attachments] + communication.notify(attachments=attachments, fetched_from_email_account=True) #notify if user is linked to account if len(incoming_mails)>0 and not frappe.local.flags.in_test: @@ -342,12 +342,8 @@ class EmailAccount(Document): if names: name = names[0].get("name") # email is already available update communication uid instead - communication = frappe.get_doc("Communication", name) - communication.uid = uid - communication.save(ignore_permissions=True) - communication._attachments = [] - - return communication + frappe.db.set_value("Communication", name, "uid", uid) + return communication = frappe.get_doc({ "doctype": "Communication",