chore: get_contacts only if email account is set

This commit is contained in:
Chinmay Pai 2020-05-07 18:54:55 +05:30 committed by GitHub
parent 9b4e5c5a14
commit 413ff349ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -258,7 +258,10 @@ class Communication(Document):
# Timeline Links
def set_timeline_links(self):
contacts = get_contacts([self.sender, self.recipients, self.cc, self.bcc])
if self.email_account and frappe.db.get_value("Email Account", self.email_account, "create_contact"):
contacts = get_contacts([self.sender, self.recipients, self.cc, self.bcc])
else:
contacts = []
for contact_name in contacts:
self.add_link('Contact', contact_name)
@ -337,9 +340,6 @@ def get_permission_query_conditions_for_communication(user):
.format(email_accounts=','.join(email_accounts))
def get_contacts(email_strings):
if (not self.email_account) or (self.email_account and not frappe.db.get_value("Email Account", self.email_account, "create_contact")):
return []
email_addrs = []
for email_string in email_strings: