Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mail_post_defer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from . import wizard
from .hooks import post_init_hook
25 changes: 24 additions & 1 deletion mail_post_defer/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,27 @@ def _message_update_content(self, *args, **kwargs):
kwargs.setdefault(
"scheduled_date", fields.Datetime.now() + timedelta(seconds=30)
)
return super()._message_update_content(*args, **kwargs)

res = super()._message_update_content(*args, **kwargs)
message = args[0] if len(args) > 0 else None
body = args[1] if len(args) > 1 else None

if message and body is not None:
mails = (
self.env["mail.mail"]
.sudo()
.search(
[
("mail_message_id", "=", message.id),
("state", "=", "outgoing"),
]
)
)
if mails:
mails.write(
{
"body_html": message.body,
}
)

return res
1 change: 1 addition & 0 deletions mail_post_defer/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_compose_message
28 changes: 28 additions & 0 deletions mail_post_defer/wizard/mail_compose_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2025 Moduon Team S.L. <[email protected]>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from datetime import timedelta

from odoo import fields, models


class MailComposer(models.TransientModel):
_inherit = "mail.compose.message"

def _action_send_mail_comment(self, res_ids):
self.ensure_one()
self = self.with_context(
mail_notify_force_send=False,
)
return super()._action_send_mail_comment(res_ids)

def action_send_mail(self):
res = super().action_send_mail()
for mail in self.env["mail.mail"].browse(
self.env.context.get("mail_mail_ids", [])
):
if mail.state == "outgoing":
mail.sudo().write(
{"scheduled_date": fields.Datetime.now() + timedelta(seconds=30)}
)
return res