From 2da4bafa1e918ce2d43202a19130daf94dec015c Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Tue, 11 Jul 2017 06:53:06 +0200 Subject: [PATCH] Clear outbox modification (#3628) * Clear Outbox modification * Correction of SQL query --- frappe/email/queue.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frappe/email/queue.py b/frappe/email/queue.py index cbcaffe738..05444dabc9 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -475,8 +475,7 @@ def clear_outbox(): frappe.db.sql("""delete from `tabEmail Queue Recipient` where parent in (%s)""" % ','.join(['%s']*len(email_queues)), tuple(email_queues)) - for dt in ("Email Queue", "Email Queue Recipient"): - frappe.db.sql(""" - update `tab{0}` - set status='Expired' - where datediff(curdate(), modified) > 7 and status='Not Sent'""".format(dt)) \ No newline at end of file + frappe.db.sql(""" + update `tabEmail Queue` + set status='Expired' + where datediff(curdate(), modified) > 7 and status='Not Sent' and (send_after is null or send_after < %(now)s)""", { 'now': now_datetime() })