Skip to content

Commit

Permalink
[MIG] mail_autogenerated_header: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guewen committed Sep 11, 2024
1 parent 2d87b92 commit c9a12f4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 40 deletions.
2 changes: 1 addition & 1 deletion mail_autogenerated_header/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Autogenerated headers",
"version": "12.0.1.0.0",
"version": "14.0.1.0.0",
"author": "Hunki Enterprises BV, Therp BV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"license": "AGPL-3",
Expand Down
1 change: 0 additions & 1 deletion mail_autogenerated_header/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import ir_mail_server
from . import mail_thread
from . import res_partner
2 changes: 1 addition & 1 deletion mail_autogenerated_header/models/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def send_email(
# https://tools.ietf.org/html/rfc3834
message["Auto-Submitted"] = "auto-generated"

return super(IrMailServer, self).send_email(
return super().send_email(
message,
mail_server_id=mail_server_id,
smtp_server=smtp_server,
Expand Down
13 changes: 10 additions & 3 deletions mail_autogenerated_header/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@ class MailThread(models.AbstractModel):
_inherit = "mail.thread"

@api.model
def message_route_process(self, message, message_dict, routes):
def _message_route_process(self, message, message_dict, routes):
"""Set context key to suppress notification for autogenerated incoming
mails"""
if self._message_route_process_autoreply(message, message_dict, routes):
_logger.info(
"Ignoring email %s from %s because it seems to be an auto " "reply",
"Ignoring email %s from %s because it seems to be an auto reply",
message.get("Message-ID"),
message.get("From"),
)
self = self.with_context(mail_autogenerated_header=message)
return super(MailThread, self).message_route_process(
return super()._message_route_process(
message,
message_dict,
routes,
)

def _notify_thread(self, message, msg_vals=False, notify_by_email=True, **kwargs):
"""Inhibit notifications if this is the notification for an incoming
autogenerated mail from another system"""
if self.env.context.get("mail_autogenerated_header"):
return False
return super()._notify_thread(message, **kwargs)

@api.model
def _message_route_process_autoreply(self, message, message_dict, routes):
"""Determine if some message is an autoreply"""
Expand Down
32 changes: 0 additions & 32 deletions mail_autogenerated_header/models/res_partner.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_receiving(self):
[("res_partner_id", "=", demo_user.partner_id.id)]
)
# mail is not autogenerated, should have generated mails
self.assertTrue(notifications.is_email)
self.assertTrue(notifications.notification_type == "email")
notifications.unlink()

reply.replace_header("Message-Id", "message_id4")
Expand All @@ -69,4 +69,4 @@ def test_receiving(self):
[("res_partner_id", "=", demo_user.partner_id.id)]
)
# mail is autogenerated, shouldn't have generated mails
self.assertFalse(notifications.is_email)
self.assertFalse(notifications.notification_type == "email")

0 comments on commit c9a12f4

Please sign in to comment.