From 4c138390b60a2537c1b4e7ee38bfdb140be3ccb4 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Wed, 1 Jan 2020 11:21:53 +0530 Subject: [PATCH] fix: move email status check to fix travis mail status wasn't being set when the check was run, so the output for any() would always be false, and none of the mails would have status set to sent in the backend. moving the check to a point after setting status for each email should fix this issue Signed-off-by: Chinmay D. Pai --- frappe/email/queue.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/email/queue.py b/frappe/email/queue.py index 9ced45ffdc..4a0a34c76e 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -382,8 +382,6 @@ def send_one(email, smtpserver=None, auto_commit=True, now=False, from_test=Fals recipients_list = frappe.db.sql('''select name, recipient, status from `tabEmail Queue Recipient` where parent=%s''', email.name, as_dict=1) - email_sent_to_any_recipient = any("Sent" == s.status for s in recipients_list) - if frappe.are_emails_muted(): frappe.msgprint(_("Emails are muted")) return @@ -427,6 +425,8 @@ def send_one(email, smtpserver=None, auto_commit=True, now=False, from_test=Fals frappe.db.sql("""update `tabEmail Queue Recipient` set status='Sent', modified=%s where name=%s""", (now_datetime(), recipient.name), auto_commit=auto_commit) + email_sent_to_any_recipient = any("Sent" == s.status for s in recipients_list) + #if all are sent set status if email_sent_to_any_recipient: frappe.db.sql("""update `tabEmail Queue` set status='Sent', modified=%s where name=%s""",