diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-07-28 15:09:55 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-07-28 15:09:55 +0700 |
| commit | d15ce4e186e2b77f01e8dfd03886298cc733d4c1 (patch) | |
| tree | 1b32a4c29c4fcea85070fcecb5b77a7d55d30029 /indoteknik_custom/models/mail_mail.py | |
| parent | deba962d7368a5c4e30441b5a640102608e3dde6 (diff) | |
| parent | 36a53535dbdc5777266fd9276b4c557259dab6be (diff) | |
<hafid> merging odoo-backup
Diffstat (limited to 'indoteknik_custom/models/mail_mail.py')
| -rw-r--r-- | indoteknik_custom/models/mail_mail.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/indoteknik_custom/models/mail_mail.py b/indoteknik_custom/models/mail_mail.py index 82b1fcca..792b97b7 100644 --- a/indoteknik_custom/models/mail_mail.py +++ b/indoteknik_custom/models/mail_mail.py @@ -1,12 +1,27 @@ from odoo import fields, models, api, _ +from datetime import timedelta +import logging +_logger = logging.getLogger(__name__) class MailMail(models.Model): _inherit = 'mail.mail' + @api.model def retry_send_mail(self): - mails = self.env['mail.mail'].search([ - ('state', 'in', ['exception', 'cancel']), + now = fields.Datetime.now() + seven_days_ago = now - timedelta(days=7) + + # Filter hanya email gagal dalam 7 hari terakhir + mails = self.search([ + ('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: + _logger.info("Retrying email ID %s - To: %s - Subject: %s", + mail.id, mail.email_to, mail.subject) mail.state = 'outgoing' |
