Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ addon | version | maintainers | summary
[mail_activity_team](mail_activity_team/) | 18.0.1.0.1 | | Add Teams to Activities
[mail_attach_existing_attachment](mail_attach_existing_attachment/) | 18.0.1.0.0 | | Adding attachment on the object by sending this one
[mail_attach_existing_attachment_account](mail_attach_existing_attachment_account/) | 18.0.1.0.0 | | Module to use attach existing attachment for account module
[mail_autogenerated_header](mail_autogenerated_header/) | 18.0.1.0.0 | | Add headers to Odoo's mails indicating they are autogenerated
[mail_autogenerated_header](mail_autogenerated_header/) | 18.0.1.1.0 | | Add headers to Odoo's mails indicating they are autogenerated
[mail_autosubscribe](mail_autosubscribe/) | 18.0.1.1.0 | | Automatically subscribe partners to its company's business documents
[mail_composer_cc_bcc](mail_composer_cc_bcc/) | 18.0.1.0.2 | <a href='https://github.com/trisdoan'><img src='https://github.com/trisdoan.png' width='32' height='32' style='border-radius:50%;' alt='trisdoan'/></a> | This module enables sending mail to CC and BCC partners in mail composer form.
[mail_debrand](mail_debrand/) | 18.0.1.0.1 | <a href='https://github.com/pedrobaeza'><img src='https://github.com/pedrobaeza.png' width='32' height='32' style='border-radius:50%;' alt='pedrobaeza'/></a> <a href='https://github.com/joao-p-marques'><img src='https://github.com/joao-p-marques.png' width='32' height='32' style='border-radius:50%;' alt='joao-p-marques'/></a> | Remove Odoo branding in sent emails Removes anchor <a href odoo.com togheder with it's parent ( for powerd by) form all the templates removes any 'odoo' that are in tempalte texts > 20characters
Expand All @@ -50,7 +50,7 @@ addon | version | maintainers | summary
[mail_send_confirmation](mail_send_confirmation/) | 18.0.1.0.0 | | Mail Send Confirmation
[mail_show_follower](mail_show_follower/) | 18.0.1.0.1 | <a href='https://github.com/yajo'><img src='https://github.com/yajo.png' width='32' height='32' style='border-radius:50%;' alt='yajo'/></a> | Show CC document followers in mails.
[mail_suggested_recipient_unchecked](mail_suggested_recipient_unchecked/) | 18.0.1.0.0 | <a href='https://github.com/victoralmau'><img src='https://github.com/victoralmau.png' width='32' height='32' style='border-radius:50%;' alt='victoralmau'/></a> | Mail suggested recipient unchecked
[mail_tracking](mail_tracking/) | 18.0.1.0.5 | | Email tracking system for all mails sent
[mail_tracking](mail_tracking/) | 18.0.1.0.6 | | Email tracking system for all mails sent
[mail_tracking_mailgun](mail_tracking_mailgun/) | 18.0.1.0.0 | | Mail tracking and Mailgun webhooks integration
[mail_tracking_mass_mailing](mail_tracking_mass_mailing/) | 18.0.1.0.0 | | Improve mass mailing email tracking

Expand Down
17 changes: 11 additions & 6 deletions mail_autogenerated_header/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Autogenerated headers
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:591306323a242f6435b223e7ce1e718218d0db0b0fd45c776fa0e6715d168207
!! source digest: sha256:0dd822572bebd34c9e428fe8f7cd191012396cd99b1655fa61c5cbd8dd572bf8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -33,9 +33,9 @@ Autogenerated headers
|badge1| |badge2| |badge3| |badge4| |badge5|

This module was written to mark Odoo's emails as being autogenerated
according to `RFC 3834 <https://tools.ietf.org/html/rfc3834>`__, section
5. This allows receiving mail servers to act accordingly by for example
not sending a vacation autoreply.
according to ``RFC 3834 <https://tools.ietf.org/html/rfc3834>``\ \_,
section 5. This allows receiving mail servers to act accordingly by for
example not sending a vacation autoreply.

On the receiving side, this module drops all notifications for
autogenerated incoming e-mails.
Expand All @@ -51,9 +51,14 @@ broken email servers on the opposite side.
Usage
=====

There's nothing the user has to do. Developers can set the context flag
For sending outgoing emails, users can change the config parameter
``mail_autogenerated_header.allow_autogenerated_outgoing`` to ``False``
to avoid any outgoing emails being marked as autogenerated. For only
avoiding in certain cases, developers can set the context flag
``mail_autogenerated_header_disable`` in calls to ``send_email`` in
order to suppress adding any headers at all, and override
order to suppress adding any autogenerated headers.

For receiving incoming emails, developers can override the method
``_message_route_process_autoreply`` to fine tune dropping autogenerated
mails per model.

Expand Down
7 changes: 3 additions & 4 deletions mail_autogenerated_header/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Autogenerated headers",
"version": "18.0.1.0.0",
"version": "18.0.1.1.0",
"author": "Hunki Enterprises BV, Therp BV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/mail",
"license": "AGPL-3",
"category": "Tools",
"summary": "Add headers to Odoo's mails indicating they are autogenerated",
"depends": [
"mail",
],
"depends": ["mail"],
"data": ["data/ir_config_parameter.xml"],
}
7 changes: 7 additions & 0 deletions mail_autogenerated_header/data/ir_config_parameter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="allow_autogenerated_outgoing" model="ir.config_parameter">
<field name="key">mail_autogenerated_header.allow_autogenerated_outgoing</field>
<field name="value">True</field>
</record>
</odoo>
66 changes: 36 additions & 30 deletions mail_autogenerated_header/models/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,40 @@ def send_email(
smtp_debug=False,
smtp_session=None,
):
# Inject autogenerated header for autogoing mails

if not self.env.context.get(
"mail_autogenerated_header_disable"
) and self._send_email_set_autogenerated(
message,
mail_server_id=mail_server_id,
smtp_server=smtp_server,
smtp_port=smtp_port,
smtp_user=smtp_user,
smtp_password=smtp_password,
smtp_encryption=smtp_encryption,
smtp_ssl_certificate=smtp_ssl_certificate,
smtp_ssl_private_key=smtp_ssl_private_key,
smtp_debug=smtp_debug,
smtp_session=smtp_session,
):
# MS Exchange's broken version as of
# http://blogs.technet.com/b/exchange/archive/2006/10/06/
# 3395024.aspx
message["Precedence"] = "bulk"
message["X-Auto-Response-Suppress"] = "OOF"
# The right way to do it as of
# https://tools.ietf.org/html/rfc3834
message["Auto-Submitted"] = "auto-generated"
# Inject autogenerated header for outgoing mails
allow_autogenerated_outgoing = (
self.env["ir.config_parameter"]
.sudo()
.get_param("mail_autogenerated_header.allow_autogenerated_outgoing", False)
)
if allow_autogenerated_outgoing:
mail_autogenerated_header_disable = self.env.context.get(
"mail_autogenerated_header_disable"
)
if (
not mail_autogenerated_header_disable
and self._send_email_set_autogenerated(
message,
mail_server_id=mail_server_id,
smtp_server=smtp_server,
smtp_port=smtp_port,
smtp_user=smtp_user,
smtp_password=smtp_password,
smtp_encryption=smtp_encryption,
smtp_ssl_certificate=smtp_ssl_certificate,
smtp_ssl_private_key=smtp_ssl_private_key,
smtp_debug=smtp_debug,
smtp_session=smtp_session,
)
):
# MS Exchange's broken version as of
# http://blogs.technet.com/b/exchange/archive/2006/10/06/
# 3395024.aspx
message["Precedence"] = "bulk"
message["X-Auto-Response-Suppress"] = "OOF"
# The right way to do it as of
# https://tools.ietf.org/html/rfc3834
message["Auto-Submitted"] = "auto-generated"

return super().send_email(
message,
Expand Down Expand Up @@ -77,12 +86,9 @@ def _send_email_set_autogenerated(
smtp_debug=False,
smtp_session=None,
):
"""Determine if some mail should have the autogenerated headers"""

# Determine if some mail should have the autogenerated headers
mail = self.env["mail.mail"].search(
[
("message_id", "=", message["Message-Id"]),
]
[("message_id", "=", message["Message-Id"])]
)
if not mail:
return False
Expand Down
7 changes: 3 additions & 4 deletions mail_autogenerated_header/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
This module was written to mark Odoo's emails as being autogenerated
according to [RFC 3834](https://tools.ietf.org/html/rfc3834), section 5.
This allows receiving mail servers to act accordingly by for example not
sending a vacation autoreply.
This module was written to mark Odoo's emails as being autogenerated according
to `RFC 3834 <https://tools.ietf.org/html/rfc3834>`_, section 5. This allows
receiving mail servers to act accordingly by for example not sending a vacation autoreply.

On the receiving side, this module drops all notifications for
autogenerated incoming e-mails.
Expand Down
15 changes: 10 additions & 5 deletions mail_autogenerated_header/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
There's nothing the user has to do. Developers can set the context flag
`mail_autogenerated_header_disable` in calls to `send_email` in order to
suppress adding any headers at all, and override
`_message_route_process_autoreply` to fine tune dropping autogenerated
mails per model.
For sending outgoing emails, users can change the config parameter
``mail_autogenerated_header.allow_autogenerated_outgoing`` to ``False`` to
avoid any outgoing emails being marked as autogenerated. For only avoiding
in certain cases, developers can set the context flag
``mail_autogenerated_header_disable`` in calls to ``send_email`` in order to
suppress adding any autogenerated headers.

For receiving incoming emails, developers can override the method
``_message_route_process_autoreply`` to fine tune dropping autogenerated mails
per model.
16 changes: 10 additions & 6 deletions mail_autogenerated_header/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ <h1>Autogenerated headers</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:591306323a242f6435b223e7ce1e718218d0db0b0fd45c776fa0e6715d168207
!! source digest: sha256:0dd822572bebd34c9e428fe8f7cd191012396cd99b1655fa61c5cbd8dd572bf8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_autogenerated_header"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_autogenerated_header"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module was written to mark Odoo’s emails as being autogenerated
according to <a class="reference external" href="https://tools.ietf.org/html/rfc3834">RFC 3834</a>, section
5. This allows receiving mail servers to act accordingly by for example
not sending a vacation autoreply.</p>
according to <tt class="docutils literal">RFC 3834 <span class="pre">&lt;https://tools.ietf.org/html/rfc3834&gt;</span></tt>_,
section 5. This allows receiving mail servers to act accordingly by for
example not sending a vacation autoreply.</p>
<p>On the receiving side, this module drops all notifications for
autogenerated incoming e-mails.</p>
<p>The combination of both avoids possible mail loops with misconfigured or
Expand All @@ -398,9 +398,13 @@ <h1>Autogenerated headers</h1>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<p>There’s nothing the user has to do. Developers can set the context flag
<p>For sending outgoing emails, users can change the config parameter
<tt class="docutils literal">mail_autogenerated_header.allow_autogenerated_outgoing</tt> to <tt class="docutils literal">False</tt>
to avoid any outgoing emails being marked as autogenerated. For only
avoiding in certain cases, developers can set the context flag
<tt class="docutils literal">mail_autogenerated_header_disable</tt> in calls to <tt class="docutils literal">send_email</tt> in
order to suppress adding any headers at all, and override
order to suppress adding any autogenerated headers.</p>
<p>For receiving incoming emails, developers can override the method
<tt class="docutils literal">_message_route_process_autoreply</tt> to fine tune dropping autogenerated
mails per model.</p>
</div>
Expand Down
28 changes: 16 additions & 12 deletions mail_autogenerated_header/tests/test_mail_autogenerated_header.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2018 Therp BV <https://therp.nl>
# Copyright 2022 Hunki Enterprises BV <https://hunki-enterprises.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import copy

from odoo.tools.mail import generate_tracking_message_id

from odoo.addons.base.tests.common import BaseCommon
Expand All @@ -18,7 +20,7 @@ def setUpClass(cls):
"message_id": "message_id",
}
)
cls.message = cls.env["ir.mail_server"].build_email(
cls.base_message = cls.env["ir.mail_server"].build_email(
[cls.mail.email_from],
[cls.mail.email_to],
cls.mail.subject,
Expand All @@ -28,34 +30,37 @@ def setUpClass(cls):

def test_sending(self):
"""Test that sending a mail has the Auto-Submitted header"""
self.message = copy.deepcopy(self.base_message)
self.env["ir.mail_server"].send_email(self.message)
self.assertEqual(self.message["Auto-Submitted"], "auto-generated")
# Test that the header is not set when the parameter is disabled
self.env["ir.config_parameter"].sudo().set_param(
"mail_autogenerated_header.allow_autogenerated_outgoing", False
)
self.message = copy.deepcopy(self.base_message)
self.env["ir.mail_server"].send_email(self.message)
self.assertNotIn("Auto-Submitted", self.message)

def test_receiving(self):
"""Test that receiving mails with some auto submitted marker won't
cause new notifications being sent"""
self.message = copy.deepcopy(self.base_message)
demo_user = self.env.ref("base.user_demo")
self.message.replace_header(
"Message-Id",
generate_tracking_message_id(42),
)

self.message.replace_header("Message-Id", generate_tracking_message_id(42))
self.env["mail.notification"].search(
[("res_partner_id", "=", demo_user.partner_id.id)]
).unlink()

partner_id = self.env["mail.thread"].message_process(
"res.partner",
self.message.as_string(),
"res.partner", self.message.as_string()
)
partner = self.env["res.partner"].browse(partner_id)
partner.message_subscribe(partner_ids=demo_user.partner_id.ids)
reply = self.message
reply["References"] = self.message["Message-Id"]
reply.replace_header("Message-Id", "message_id3")
thread_id = self.env["mail.thread"].message_process(
"res.partner",
reply.as_string(),
"res.partner", reply.as_string()
)
self.assertEqual(thread_id, partner.id)
notifications = self.env["mail.notification"].search(
Expand All @@ -68,8 +73,7 @@ def test_receiving(self):
reply.replace_header("Message-Id", "message_id4")
reply["Auto-Submitted"] = "auto-generated"
thread_id = self.env["mail.thread"].message_process(
"res.partner",
reply.as_string(),
"res.partner", reply.as_string()
)
self.assertEqual(thread_id, partner.id)
notifications = self.env["mail.notification"].search(
Expand Down
2 changes: 1 addition & 1 deletion mail_tracking/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Email tracking
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1dcb2ce7cde25d536c483309729542a0a80d35e24af13a43d9903a6284c3955f
!! source digest: sha256:1f1623a6f08afa9507deebf534e7eb24325927d829724858b58a3c9bb5bc2cb4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion mail_tracking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "Email tracking",
"summary": "Email tracking system for all mails sent",
"version": "18.0.1.0.5",
"version": "18.0.1.0.6",
"category": "Social Network",
"website": "https://github.com/OCA/mail",
"author": ("Tecnativa, Odoo Community Association (OCA)"),
Expand Down
4 changes: 3 additions & 1 deletion mail_tracking/models/mail_tracking_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def _get_allowed_ids(self, ids):
)
)
result = self.env.cr.fetchall()
_, msg_ids, mail_ids, partner_ids = zip(*result, strict=True)
msg_ids, mail_ids, partner_ids = [], [], []
if result:
_, msg_ids, mail_ids, partner_ids = zip(*result, strict=True)
msg_ids = (
self.env["mail.message"]
.search([("id", "in", [x for x in msg_ids if x])])
Expand Down
2 changes: 1 addition & 1 deletion mail_tracking/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Email tracking</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1dcb2ce7cde25d536c483309729542a0a80d35e24af13a43d9903a6284c3955f
!! source digest: sha256:1f1623a6f08afa9507deebf534e7eb24325927d829724858b58a3c9bb5bc2cb4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_tracking"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_tracking"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module shows email notification tracking status for any messages in
Expand Down