diff options
| -rw-r--r-- | indoteknik_custom/models/mail_mail.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/indoteknik_custom/models/mail_mail.py b/indoteknik_custom/models/mail_mail.py index 7ebd9293..cbcd883a 100644 --- a/indoteknik_custom/models/mail_mail.py +++ b/indoteknik_custom/models/mail_mail.py @@ -1,6 +1,8 @@ from odoo import fields, models, api, _ from datetime import timedelta +import logging +_logger = logging.getLogger(__name__) class MailMail(models.Model): _inherit = 'mail.mail' @@ -12,10 +14,14 @@ class MailMail(models.Model): # Filter hanya email gagal dalam 7 hari terakhir mails = self.search([ - ('state', 'in', ['exception', 'cancel']), + ('state', 'in', 'exception'), ('create_date', '>=', seven_days_ago), ('create_date', '<=', now), ], limit=250) + _logger.info("Found %s failed emails in last 7 days to retry.", len(mails)) + for mail in mails: - mail.state = 'outgoing' + _logger.info("Retrying email ID %s - To: %s - Subject: %s", + mail.id, mail.email_to, mail.subject) + mail.state = 'outgoing' |
