Erpnext: [v12] Can't send Documents via Email after upgrading to v12

Created on 16 Sep 2019  路  15Comments  路  Source: frappe/erpnext

Installed Apps
ERPNext: v12.1.2 (version-12)
Frappe Framework: v12.0.12 (version-12)

After upgrading to ERPNext v12 I receive the following error when I try to send a document via email.

image

Most helpful comment

It is still not possible for me to send emails. Has anyone an idea how to fix it?

Here the Traceback:

Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
response = frappe.api.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
return frappe.call(method, frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/
init*.py", line 1036, in call
return fn(
args, *newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 73, in make
}).insert(ignore_permissions=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 228, in insert
self.run_before_save_methods()
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 886, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
out = Document.hook(fn)(self, *args, *
kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1056, in composer
return composed(self, method, args, *kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1039, in runner
add_to_return_value(self, fn(self, args, *kwargs))
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in
fn = lambda self, args, *kwargs: getattr(self, method)(args, *kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 65, in validate
self.set_timeline_links()
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 263, in set_timeline_links
self.add_link('Contact', contact_name)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 288, in add_link
"link_name": link_name
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 149, in append
value = self._init_child(value, key)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 184, in _init_child
value["doctype"] = self.get_table_field_doctype(key)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 298, in get_table_field_doctype
return self.meta.get_field(fieldname).options
AttributeError: 'NoneType' object has no attribute 'options'

  • The problem is Communication doctype wasn't reloaded properly, so the code is new but the doctype structure is old which is causing this error.
  • Goto python console and reload the communication and communication_link doctype and this should be fixed.

All 15 comments

When I click on "Bericht" (report) the message tells me that a support email is not given. Does that rely to the error or is it just an info that no default support email is available?

image

You need to create an Email Address and set it as Default Outgoing or setup the email account in the user record.

Thanks for your reply. Everything has been set already in v11 before the upgrade. Do I have to reset the email setup?

The notification email is set as my default outgoing email address and that worked in v11.

image

I've just deleted the old email-address and created a new one. The error persists.

See this discussion https://discuss.erpnext.com/t/how-to-set-support-email-address-for-server-error/52156

https://github.com/frappe/frappe/issues/8300

Please post this to discuss.erpenxt.com to benefit all to resolve.

Copy and paste the traceback, as a screenshot hinders code browsing.

Installed Apps ERPNext: v12.1.2 (version-12) Frappe Framework: v12.0.12 (version-12)

After upgrading to ERPNext v12 I receive the following error when I try to send a document via email.

image

  • Can you check if python files for Communication DocType exists
  • I had encountered somewhat the same issue and turned out that Communication DocType fiels were deleted.

Installed Apps ERPNext: v12.1.2 (version-12) Frappe Framework: v12.0.12 (version-12)
After upgrading to ERPNext v12 I receive the following error when I try to send a document via email.
image

  • Can you check if python files for Communication DocType exists
  • I had encountered somewhat the same issue and turned out that Communication DocType fiels were deleted.

There are python files in

  • erpnext/erpnext/communication/call_log
  • erpnext/erpnext/communication/communication_medium
  • erpnext/erpnext/communication/communication_medium_timeslot

How did you fix the issue?

It is still not possible for me to send emails. Has anyone an idea how to fix it?

Here the Traceback:

Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
response = frappe.api.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
return frappe.call(method, *frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
return fn(
args, *newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 73, in make
}).insert(ignore_permissions=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 228, in insert
self.run_before_save_methods()
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 886, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
out = Document.hook(fn)(self, *args, *
kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1056, in composer
return composed(self, method, args, *kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1039, in runner
add_to_return_value(self, fn(self, args, *kwargs))
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in
fn = lambda self, args, *kwargs: getattr(self, method)(args, *kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 65, in validate
self.set_timeline_links()
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 263, in set_timeline_links
self.add_link('Contact', contact_name)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 288, in add_link
"link_name": link_name
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 149, in append
value = self._init_child(value, key)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 184, in _init_child
value["doctype"] = self.get_table_field_doctype(key)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 298, in get_table_field_doctype
return self.meta.get_field(fieldname).options
AttributeError: 'NoneType' object has no attribute 'options'

See this discussion https://discuss.erpnext.com/t/how-to-set-support-email-address-for-server-error/52156

frappe/frappe#8300

Please post this to discuss.erpenxt.com to benefit all to resolve.

Copy and paste the traceback, as a screenshot hinders code browsing.

Please also refer: https://discuss.erpnext.com/t/v12-cant-send-documents-via-email-after-upgrading-to-v12/53278/3

I was able to narrow down the error.

The first issue is related to timeline links.

In https://github.com/frappe/frappe/blob/develop/frappe/core/doctype/communication/communication.py I commented out line 65 and 66

if self.communication_medium == "Email":
  self.parse_email_for_timeline_links()
  # self.set_timeline_links()
  # self.deduplicate_timeline_links()

Timeline links is a new feature introduced in v12 (see https://erpnext.com/docs/user/manual/en/setting-up/email/linking-emails-to-document).

I have disabled the automatic linking in my email account. I suppose that the two methods should not be executed in that case.

Can anyone of the frappe core team please check that? @clarkejj

Another problem arises with smtp because of python3.6:

(501, b'Syntax error - line too long')
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 406, in send_one
    smtpserver.sess.sendmail(email.sender, recipient.recipient, encode(message))
  File "/usr/lib64/python3.6/smtplib.py", line 888, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (501, b'Syntax error - line too long')

After migrating back to python2.7 emails are sent with attachements as expected.

It is still not possible for me to send emails. Has anyone an idea how to fix it?

Here the Traceback:

Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
response = frappe.api.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
return frappe.call(method, frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/
init*.py", line 1036, in call
return fn(
args, *newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 73, in make
}).insert(ignore_permissions=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 228, in insert
self.run_before_save_methods()
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 886, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
out = Document.hook(fn)(self, *args, *
kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1056, in composer
return composed(self, method, args, *kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1039, in runner
add_to_return_value(self, fn(self, args, *kwargs))
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in
fn = lambda self, args, *kwargs: getattr(self, method)(args, *kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 65, in validate
self.set_timeline_links()
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 263, in set_timeline_links
self.add_link('Contact', contact_name)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 288, in add_link
"link_name": link_name
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 149, in append
value = self._init_child(value, key)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 184, in _init_child
value["doctype"] = self.get_table_field_doctype(key)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 298, in get_table_field_doctype
return self.meta.get_field(fieldname).options
AttributeError: 'NoneType' object has no attribute 'options'

  • The problem is Communication doctype wasn't reloaded properly, so the code is new but the doctype structure is old which is causing this error.
  • Goto python console and reload the communication and communication_link doctype and this should be fixed.

Thanks @hrwX

this solved.

bench --force reload-doc core doctype communication_link
bench --force reload-doc core doctype communication

Can confirm that reloading the doctypes worked. Thx for the support!

Another problem arises with smtp because of python3.6:

(501, b'Syntax error - line too long')
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 406, in send_one
    smtpserver.sess.sendmail(email.sender, recipient.recipient, encode(message))
  File "/usr/lib64/python3.6/smtplib.py", line 888, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (501, b'Syntax error - line too long')

After migrating back to python2.7 emails are sent with attachements as expected.

@ophl55 @jigneshpshah - Does the smtp issue with python3.6 also resolve with above command?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jboilesen picture jboilesen  路  3Comments

giuseppelamatrice picture giuseppelamatrice  路  3Comments

Fredoluka picture Fredoluka  路  3Comments

nabinhait picture nabinhait  路  4Comments

mubeenmazhar picture mubeenmazhar  路  4Comments