only send to customer for credit notes linked to a user object

This commit is contained in:
Thomas Steen Rasmussen 2017-09-17 14:32:21 +02:00
parent c0f2478819
commit 88cb7934c1

View file

@ -87,8 +87,8 @@ def do_work():
creditnote.pdf.save(creditnote.filename, File(pdffile)) creditnote.pdf.save(creditnote.filename, File(pdffile))
creditnote.save() creditnote.save()
# check if we need to send out any creditnotes (only where pdf has been generated) # check if we need to send out any creditnotes (only where pdf has been generated and only for creditnotes linked to a user)
for creditnote in CreditNote.objects.filter(sent_to_customer=False).exclude(pdf=''): for creditnote in CreditNote.objects.filter(sent_to_customer=False).exclude(pdf='').exclude(user=None):
# send the email # send the email
if add_creditnote_email(creditnote=creditnote): if add_creditnote_email(creditnote=creditnote):
logger.info('OK: Creditnote email to %s added' % creditnote.user.email) logger.info('OK: Creditnote email to %s added' % creditnote.user.email)