diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-06-09 08:23:04 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-06-09 08:23:04 +0700 |
| commit | a7f3eb12ddc41a18df90a3d5519014c07c0e5d7b (patch) | |
| tree | 19c22d25852823fffff83def18a27f79a2b3567e | |
| parent | 83497bde03344da4186e1c73601636bc9928081d (diff) | |
(andri) fix retry email marketing
| -rw-r--r-- | indoteknik_custom/models/mail_mail.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/indoteknik_custom/models/mail_mail.py b/indoteknik_custom/models/mail_mail.py index 82b1fcca..7ebd9293 100644 --- a/indoteknik_custom/models/mail_mail.py +++ b/indoteknik_custom/models/mail_mail.py @@ -1,12 +1,21 @@ from odoo import fields, models, api, _ +from datetime import timedelta class MailMail(models.Model): _inherit = 'mail.mail' + @api.model def retry_send_mail(self): - mails = self.env['mail.mail'].search([ + 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', 'cancel']), + ('create_date', '>=', seven_days_ago), + ('create_date', '<=', now), ], limit=250) + for mail in mails: - mail.state = 'outgoing' + mail.state = 'outgoing' |
