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
134 changes: 134 additions & 0 deletions mail_force_email_notification/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=============================
Mail Force Email Notification
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:bc735d617f6e55d39427e192b0b118b534714ab642d16ffc1e71aa6e19394f8d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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%2Fmail-lightgray.png?logo=github
:target: https://github.com/OCA/mail/tree/19.0/mail_force_email_notification
:alt: OCA/mail
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_force_email_notification
: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/mail&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of Odoo's mail notification system
to allow forcing email notifications through context keys. By default,
Odoo sends internal notifications to connected users and email
notifications to external partners or disconnected users.

With this module, you can override this behavior by setting the
``force_notification_by_email`` context key, ensuring specific
notifications are always sent by email regardless of the user's
connection status or notification preferences. This is particularly
useful when you need to maintain an email trail for certain
communications or ensure critical notifications are delivered via email.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. For developers implementing the feature:

- Add the context key ``force_notification_by_email=True`` when
sending messages through the mail thread

.. code:: python

self.env['mail.thread'].with_context(
force_notification_by_email=True
).message_post(
body="Your message",
partner_ids=[partner.id],
)

2. For end users:

- No specific configuration is needed
- When developers have implemented the feature in specific actions:

- Messages will be sent by email regardless of your notification
preferences
- You will receive email notifications even if you are connected to
Odoo
- Your notification preferences in your user settings won't affect
these specific notifications

**Example Use Cases:**

- Critical notifications that need email documentation
- Automated workflows where email trail is required
- Compliance requirements where email proof of communication is
necessary

**Note:** This module only affects notifications where the context key
has been specifically implemented. All other notifications will follow
standard Odoo behavior.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/mail/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/mail/issues/new?body=module:%20mail_force_email_notification%0Aversion:%2019.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>`__

- Rafael Lima <[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/mail <https://github.com/OCA/mail/tree/19.0/mail_force_email_notification>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_force_email_notification/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions mail_force_email_notification/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2025 Camptocamp (http://www.camptocamp.com).
# @author Rafael Lima <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Mail Force Email Notification",
"summary": "Context key to define notifications to be sent by email"
"defined by force_notification_by_email context key",
"version": "19.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Hidden",
"depends": ["mail"],
"website": "https://github.com/OCA/mail",
}
22 changes: 22 additions & 0 deletions mail_force_email_notification/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_force_email_notification
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-04-05 11:06+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.2\n"

#. module: mail_force_email_notification
#: model:ir.model,name:mail_force_email_notification.model_mail_thread
msgid "Email Thread"
msgstr "Discussione e-mail"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_force_email_notification
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mail_force_email_notification
#: model:ir.model,name:mail_force_email_notification.model_mail_thread
msgid "Email Thread"
msgstr ""
1 change: 1 addition & 0 deletions mail_force_email_notification/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_thread
18 changes: 18 additions & 0 deletions mail_force_email_notification/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models


class MailThread(models.AbstractModel):
_inherit = "mail.thread"

def _notify_get_recipients(self, message, msg_vals, **kwargs):
recipients = super()._notify_get_recipients(message, msg_vals, **kwargs)
# The context key `force_notification_by_email` allows to
# push notifications through email even if the user has his preferences
# configured to use Odoo.
if self.env.context.get("force_notification_by_email"):
for partner in recipients:
partner["notif"] = "email"
return recipients
3 changes: 3 additions & 0 deletions mail_force_email_notification/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions mail_force_email_notification/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Camptocamp](https://www.camptocamp.com)

> - Rafael Lima \<[email protected]\>
3 changes: 3 additions & 0 deletions mail_force_email_notification/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module extends the functionality of Odoo's mail notification system to allow forcing email notifications through context keys. By default, Odoo sends internal notifications to connected users and email notifications to external partners or disconnected users.

With this module, you can override this behavior by setting the `force_notification_by_email` context key, ensuring specific notifications are always sent by email regardless of the user's connection status or notification preferences. This is particularly useful when you need to maintain an email trail for certain communications or ensure critical notifications are delivered via email.
27 changes: 27 additions & 0 deletions mail_force_email_notification/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
To use this module, you need to:

1. For developers implementing the feature:
- Add the context key `force_notification_by_email=True` when sending messages through the mail thread
```python
self.env['mail.thread'].with_context(
force_notification_by_email=True
).message_post(
body="Your message",
partner_ids=[partner.id],
)
```

2. For end users:
- No specific configuration is needed
- When developers have implemented the feature in specific actions:
- Messages will be sent by email regardless of your notification preferences
- You will receive email notifications even if you are connected to Odoo
- Your notification preferences in your user settings won't affect these specific notifications

**Example Use Cases:**

- Critical notifications that need email documentation
- Automated workflows where email trail is required
- Compliance requirements where email proof of communication is necessary

**Note:** This module only affects notifications where the context key has been specifically implemented. All other notifications will follow standard Odoo behavior.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading