-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[17.0][ADD] mail_prevent_bounce_loop #1419
Open
trisdoan
wants to merge
1
commit into
OCA:17.0
Choose a base branch
from
trisdoan:17.0-add-mail_bounce
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
======================== | ||
Mail Prevent Bounce Loop | ||
======================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:a2c5d232ac1c492e303d58e122afb9f061be446596049b2431a4105fd481f04e | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github | ||
:target: https://github.com/OCA/social/tree/17.0/mail_prevent_bounce_loop | ||
:alt: OCA/social | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_prevent_bounce_loop | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module helps to prevent infinite loop between odoo and | ||
autoresponder, which is currently raised in | ||
`here <https://github.com/odoo/odoo/issues/132666>`__ | ||
|
||
- Case 1: odoo sends an invoice email to customer mail address, | ||
autoresponder sends auto-reply mail (without enough information for | ||
odoo to detect it as an auto-reply: headers | ||
`-loop-detection-bounce-email@/-loop-detection-bounce-email <https://github.com/odoo/odoo/blob/9be0c5348bfeb338bcba95b2a9c01e0d7dd14306/addons/mail/models/mail_thread.py#L1373>`__). | ||
Odoo receives and send another one, resulting ping-pong situation. | ||
- Case 2: a cron, Notification: Send scheduled message notifications. | ||
When odoo receives automatic reply, the cron (running by default | ||
every hour) sends notifications to all involved followers of the | ||
mail, which then leads to the above issue | ||
|
||
Users can avoid the issue by disabling bounce mail at partner level. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To never send a bounce email to a specific email address, you can tick | ||
no_bounce_email as below: | ||
|
||
|no_bounce_email| | ||
|
||
To never send email notification when receiving auto-reply email from a | ||
specific email address identified as an auto-reply address, you can tick | ||
is_automatic_reply_address as below: | ||
|
||
|is_automatic_reply| | ||
|
||
.. |no_bounce_email| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_prevent_bounce_loop/static/img/no_bounce_email.png | ||
.. |is_automatic_reply| image:: https://raw.githubusercontent.com/OCA/social/17.0/mail_prevent_bounce_loop/static/img/is_automatic_reply.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_prevent_bounce_loop%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
------------ | ||
|
||
- `Camptocamp <https://www.camptocamp.com>`__ | ||
|
||
- Anna <[email protected]> | ||
- Tri Doan <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/social <https://github.com/OCA/social/tree/17.0/mail_prevent_bounce_loop>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Mail Prevent Bounce Loop", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/social", | ||
"category": "Social Network", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"version": "17.0.1.0.0", | ||
"depends": ["mail"], | ||
"data": [ | ||
"views/res_partner.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import res_partner | ||
from . import mail_thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright 2024 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
import logging | ||
|
||
from odoo import models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class MailThread(models.AbstractModel): | ||
_inherit = "mail.thread" | ||
|
||
def _routing_create_bounce_email( | ||
self, email_from, body_html, message, **mail_values | ||
): | ||
partner = self._mail_find_partner_from_emails([email_from]) | ||
if partner and partner[0].no_bounce_email: | ||
_logger.info("No bounce email sent to %s", email_from) | ||
return True | ||
super()._routing_create_bounce_email( | ||
email_from, body_html, message, **mail_values | ||
) | ||
|
||
def _notify_thread_by_email( | ||
self, | ||
message, | ||
recipients_data, | ||
msg_vals=False, | ||
mail_auto_delete=True, | ||
model_description=False, | ||
force_email_company=False, | ||
force_email_lang=False, | ||
resend_existing=False, | ||
force_send=True, | ||
send_after_commit=True, | ||
subtitles=None, | ||
**kwargs, | ||
): | ||
email_from = message.email_from | ||
email_from_partner = self._mail_find_partner_from_emails([email_from]) | ||
if email_from_partner and email_from_partner[0].is_automatic_reply_address: | ||
_logger.info( | ||
"No notification sent to followers for email received from %s", | ||
email_from, | ||
) | ||
return True | ||
return super()._notify_thread_by_email( | ||
message, | ||
recipients_data, | ||
msg_vals, | ||
mail_auto_delete, | ||
model_description, | ||
force_email_company, | ||
force_email_lang, | ||
resend_existing, | ||
force_send, | ||
send_after_commit, | ||
subtitles, | ||
**kwargs, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
no_bounce_email = fields.Boolean( | ||
help="When checked, bounced emails will not be forwarded to this address" | ||
) | ||
is_automatic_reply_address = fields.Boolean( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this name a little misleading, better use one that expresses what this does, as in |
||
help="When checked, any email received from this address will not be forwarded" | ||
"to the followers of a conversation (chatter)", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- [Camptocamp](https://www.camptocamp.com) | ||
- Anna \<<[email protected]>\> | ||
- Tri Doan \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This module helps to prevent infinite loop between odoo and | ||
autoresponder, which is currently raised in [here](<https://github.com/odoo/odoo/issues/132666>) | ||
- Case 1: odoo sends an invoice email to customer mail address, autoresponder sends auto-reply mail (without enough information for | ||
odoo to detect it as an auto-reply: headers [-loop-detection-bounce-email@/-loop-detection-bounce-email](https://github.com/odoo/odoo/blob/9be0c5348bfeb338bcba95b2a9c01e0d7dd14306/addons/mail/models/mail_thread.py#L1373)). Odoo receives and | ||
send another one, resulting ping-pong situation. | ||
- Case 2: a cron, Notification: Send scheduled | ||
message notifications. When odoo receives automatic reply, the cron | ||
(running by default every hour) sends notifications to all involved | ||
followers of the mail, which then leads to the above issue | ||
|
||
Users can avoid the issue by disabling bounce mail at partner level. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
To never send a bounce email to a specific email address, you can tick | ||
no_bounce_email as below: | ||
|
||
![no_bounce_email](../static/img/no_bounce_email.png) | ||
|
||
To never send email notification when receiving auto-reply email from a | ||
specific email address identified as an auto-reply address, you can tick is_automatic_reply_address as | ||
below: | ||
|
||
![is_automatic_reply](../static/img/is_automatic_reply.png) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in odoo this seems to be not well displayed: