fix(email): check if communication hasattr for attachment

fixes issue where previous communication has no attribute _attachments
before it fails, causing the following error:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 99, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 724, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 295, in receive
    attachments = [d.file_name for d in communication._attachments]
AttributeError: 'Communication' object has no attribute '_attachments'

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
Chinmay D. Pai 2020-01-05 00:28:55 +05:30
parent 0e5e3497b1
commit fb511b1dfd
No known key found for this signature in database
GPG key ID: 75507BE256F40CED

View file

@ -293,7 +293,7 @@ class EmailAccount(Document):
else:
frappe.db.commit()
if communication:
if communication and hasattr(communication, "_attachments"):
attachments = [d.file_name for d in communication._attachments]
communication.notify(attachments=attachments, fetched_from_email_account=True)