Recurring Sales Invoice Failed

Recurring sales invoice Failed: as long as the notification is checked. When notification is unchecked. Recurring invoice created. If it is checked, the following error appears and subscription disabled.

Recurring Sales Invoice Failed

An error occured while creating recurring Sales Invoice SINV-1801003 for (Customer Name).
This could be because of some invalid Email Addresses in the Sales Invoice.
To stop sending repetitive error notifications from the system, we have checked Disabled field in the subscription SUB-00010 for the Sales Invoice SINV-1801003.
Please correct the Sales Invoice and unchcked Disabled in the SUB-00010 for making recurring again.

It is necessary to take this action today itself for the above mentioned recurring Sales Invoice to be generated. If delayed, you will have to manually change the “Repeat on Day of Month” field of this Sales Invoice for generating the recurring Sales Invoice in the subscription SUB-00010.
[This email is autogenerated]

I have verified the email addresses. They were correct. Also, any change on subscription is not valid. That means to modify the subscription (Repeat on day, Notify by email, End date), basically the subscription has to be canceled and recreated.

Have you checked if you can send emails to that particular email id from your ERPNext instance / Server?

Yes. I had to manually emailed each invoice after it was created. I have currently three subscriptions and all had errors when they were created with Notify by email enabled.

This is the error message:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/subscription/”, line 132, in create_documents
send_notification(doc, data, print_format=print_format)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/subscription/”, line 250, in send_notification
subject=subject, message=message, attachments=attachments)
UnboundLocalError: local variable ‘subject’ referenced before assignment


Did you get a solution to this??