diff --git a/mail_no_user_assign_notification/README.rst b/mail_no_user_assign_notification/README.rst new file mode 100644 index 000000000..6347a4fbe --- /dev/null +++ b/mail_no_user_assign_notification/README.rst @@ -0,0 +1,119 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================ +Mail No user Assign Notification +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2258ebf0f9828ca3d8384d904798cf7e1e4d0d9deb76aa232524103948b1c5de + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/mail_no_user_assign_notification + :alt: OCA/mail +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_no_user_assign_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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module inhibits the assignation notification from the models that +we want. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +1. Go to Settings > Technical > System Parameters +2. Edit "mailno_user_assign_notification.models" key record +3. Set any model\* (for example: res.partner). + +NOTE1: It is possible to set several models separated by comma (e.g.: +model1,model2). + +NOTE2: The model should have the field user_id for this to be effective. + +Usage +===== + +1. Go to one of the configured models (like Contacts). +2. Create or edit a record, and assign the field for the user (in + contacts, it's called "Salesperson", in purchase orders it's + "Purchase representative", etc). +3. The user won't receive the automatic assignment email. + +Known issues / Roadmap +====================== + +- This is not valid for project tasks users assignation, as the field is + multi-relational. A specific extension would be needed. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Víctor Martínez + - Pedro M. Baeza + +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. + +.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/mail `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_no_user_assign_notification/__init__.py b/mail_no_user_assign_notification/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mail_no_user_assign_notification/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_no_user_assign_notification/__manifest__.py b/mail_no_user_assign_notification/__manifest__.py new file mode 100644 index 000000000..7ef563844 --- /dev/null +++ b/mail_no_user_assign_notification/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Mail No user Assign Notification", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/mail", + "version": "19.0.1.0.0", + "depends": ["mail"], + "license": "AGPL-3", + "category": "Discuss", + "data": ["data/ir_config_parameter.xml"], + "installable": True, + "maintainers": ["victoralmau"], +} diff --git a/mail_no_user_assign_notification/data/ir_config_parameter.xml b/mail_no_user_assign_notification/data/ir_config_parameter.xml new file mode 100644 index 000000000..d33db04f7 --- /dev/null +++ b/mail_no_user_assign_notification/data/ir_config_parameter.xml @@ -0,0 +1,7 @@ + + + + mail_no_user_assign_notification.models + + + diff --git a/mail_no_user_assign_notification/i18n/de.po b/mail_no_user_assign_notification/i18n/de.po new file mode 100644 index 000000000..c1003b38f --- /dev/null +++ b/mail_no_user_assign_notification/i18n/de.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_no_user_assign_notification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-02-17 13:09+0000\n" +"Last-Translator: MJD \n" +"Language-Team: none\n" +"Language: de\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.15.2\n" + +#. module: mail_no_user_assign_notification +#: model:ir.model,name:mail_no_user_assign_notification.model_mail_thread +msgid "Email Thread" +msgstr "E-Mail-Thread" diff --git a/mail_no_user_assign_notification/i18n/es.po b/mail_no_user_assign_notification/i18n/es.po new file mode 100644 index 000000000..3fa5c046b --- /dev/null +++ b/mail_no_user_assign_notification/i18n/es.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_no_user_assign_notification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-05-30 15:32+0000\n" +"PO-Revision-Date: 2024-05-30 17:33+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.0.1\n" + +#. module: mail_no_user_assign_notification +#: model:ir.model,name:mail_no_user_assign_notification.model_mail_thread +msgid "Email Thread" +msgstr "Hilo de mensajes" diff --git a/mail_no_user_assign_notification/i18n/it.po b/mail_no_user_assign_notification/i18n/it.po new file mode 100644 index 000000000..18fa4e3e6 --- /dev/null +++ b/mail_no_user_assign_notification/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_no_user_assign_notification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-04-05 08:50+0000\n" +"Last-Translator: mymage \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_no_user_assign_notification +#: model:ir.model,name:mail_no_user_assign_notification.model_mail_thread +msgid "Email Thread" +msgstr "Discussione e-mail" diff --git a/mail_no_user_assign_notification/i18n/mail_no_user_assign_notification.pot b/mail_no_user_assign_notification/i18n/mail_no_user_assign_notification.pot new file mode 100644 index 000000000..b7028132e --- /dev/null +++ b/mail_no_user_assign_notification/i18n/mail_no_user_assign_notification.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_no_user_assign_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_no_user_assign_notification +#: model:ir.model,name:mail_no_user_assign_notification.model_mail_thread +msgid "Email Thread" +msgstr "" diff --git a/mail_no_user_assign_notification/models/__init__.py b/mail_no_user_assign_notification/models/__init__.py new file mode 100644 index 000000000..f2f13374b --- /dev/null +++ b/mail_no_user_assign_notification/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import mail_thread diff --git a/mail_no_user_assign_notification/models/mail_thread.py b/mail_no_user_assign_notification/models/mail_thread.py new file mode 100644 index 000000000..28b02c666 --- /dev/null +++ b/mail_no_user_assign_notification/models/mail_thread.py @@ -0,0 +1,24 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models + + +class MailThread(models.AbstractModel): + _inherit = "mail.thread" + + def _message_auto_subscribe_followers(self, updated_values, default_subtype_ids): + """Remove user_id from updated_values if this model has been set. + This will prevent the user from auto subscrube to records on creation and/or + assignment.""" + if updated_values.get("user_id"): + icp = self.sudo().env["ir.config_parameter"] + models_to_skip = icp.get_param( + "mail_no_user_assign_notification.models", "" + ) + models_to_skip = [x.strip() for x in models_to_skip.split(",")] + if self._name in models_to_skip: + updated_values.pop("user_id") + return super()._message_auto_subscribe_followers( + updated_values=updated_values, default_subtype_ids=default_subtype_ids + ) diff --git a/mail_no_user_assign_notification/pyproject.toml b/mail_no_user_assign_notification/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/mail_no_user_assign_notification/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_no_user_assign_notification/readme/CONFIGURE.md b/mail_no_user_assign_notification/readme/CONFIGURE.md new file mode 100644 index 000000000..c18b02230 --- /dev/null +++ b/mail_no_user_assign_notification/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +1. Go to Settings \> Technical \> System Parameters +2. Edit "mailno_user_assign_notification.models" key record +3. Set any model\* (for example: res.partner). + +NOTE1: It is possible to set several models separated by comma (e.g.: +model1,model2). + +NOTE2: The model should have the field user_id for this to be effective. diff --git a/mail_no_user_assign_notification/readme/CONTRIBUTORS.md b/mail_no_user_assign_notification/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..5fee39042 --- /dev/null +++ b/mail_no_user_assign_notification/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez + - Pedro M. Baeza diff --git a/mail_no_user_assign_notification/readme/DESCRIPTION.md b/mail_no_user_assign_notification/readme/DESCRIPTION.md new file mode 100644 index 000000000..e94865168 --- /dev/null +++ b/mail_no_user_assign_notification/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module inhibits the assignation notification from the models that +we want. diff --git a/mail_no_user_assign_notification/readme/ROADMAP.md b/mail_no_user_assign_notification/readme/ROADMAP.md new file mode 100644 index 000000000..e880900b8 --- /dev/null +++ b/mail_no_user_assign_notification/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- This is not valid for project tasks users assignation, as the field is + multi-relational. A specific extension would be needed. diff --git a/mail_no_user_assign_notification/readme/USAGE.md b/mail_no_user_assign_notification/readme/USAGE.md new file mode 100644 index 000000000..72ca425c5 --- /dev/null +++ b/mail_no_user_assign_notification/readme/USAGE.md @@ -0,0 +1,5 @@ +1. Go to one of the configured models (like Contacts). +2. Create or edit a record, and assign the field for the user (in + contacts, it's called "Salesperson", in purchase orders it's + "Purchase representative", etc). +3. The user won't receive the automatic assignment email. diff --git a/mail_no_user_assign_notification/static/description/icon.png b/mail_no_user_assign_notification/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mail_no_user_assign_notification/static/description/icon.png differ diff --git a/mail_no_user_assign_notification/static/description/index.html b/mail_no_user_assign_notification/static/description/index.html new file mode 100644 index 000000000..f909eb7ce --- /dev/null +++ b/mail_no_user_assign_notification/static/description/index.html @@ -0,0 +1,467 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Mail No user Assign Notification

+ +

Beta License: AGPL-3 OCA/mail Translate me on Weblate Try me on Runboat

+

This module inhibits the assignation notification from the models that +we want.

+

Table of contents

+ +
+

Configuration

+
    +
  1. Go to Settings > Technical > System Parameters
  2. +
  3. Edit “mailno_user_assign_notification.models” key record
  4. +
  5. Set any model* (for example: res.partner).
  6. +
+

NOTE1: It is possible to set several models separated by comma (e.g.: +model1,model2).

+

NOTE2: The model should have the field user_id for this to be effective.

+
+
+

Usage

+
    +
  1. Go to one of the configured models (like Contacts).
  2. +
  3. Create or edit a record, and assign the field for the user (in +contacts, it’s called “Salesperson”, in purchase orders it’s +“Purchase representative”, etc).
  4. +
  5. The user won’t receive the automatic assignment email.
  6. +
+
+
+

Known issues / Roadmap

+
    +
  • This is not valid for project tasks users assignation, as the field is +multi-relational. A specific extension would be needed.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Víctor Martínez
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

victoralmau

+

This module is part of the OCA/mail project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/mail_no_user_assign_notification/tests/__init__.py b/mail_no_user_assign_notification/tests/__init__.py new file mode 100644 index 000000000..5a63b7d7d --- /dev/null +++ b/mail_no_user_assign_notification/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_mail_no_user_assign_notification diff --git a/mail_no_user_assign_notification/tests/test_mail_no_user_assign_notification.py b/mail_no_user_assign_notification/tests/test_mail_no_user_assign_notification.py new file mode 100644 index 000000000..42b053471 --- /dev/null +++ b/mail_no_user_assign_notification/tests/test_mail_no_user_assign_notification.py @@ -0,0 +1,62 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + + +from odoo.tests import common, new_test_user + + +class TestMailNoUserAssignNotification(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user = new_test_user(cls.env, login="test_user") + cls.icp = cls.env.ref( + "mail_no_user_assign_notification.no_user_assign_notification_models" + ) + cls.icp.value = "res.partner" + # patch registry to simulate a ready environment + # so that _message_auto_subscribe_notify + # will be executed with the associated notification + cls.env.registry.ready = True + + def _get_mail_messages(self, record): + return self.env["mail.message"].search( + [("model", "=", record._name), ("res_id", "=", record.id)] + ) + + def test_partner_create(self): + partner = self.env["res.partner"].create( + { + "name": "Test partner", + "user_id": self.user.id, + } + ) + all_messages = self._get_mail_messages(partner) + # Message with user_notification is created when the assignment email is sent. + self.assertNotIn("user_notification", all_messages.mapped("message_type")) + # Remove model from config parameter (default behavior) + self.icp.value = "" + extra_partner = self.env["res.partner"].create( + { + "name": "Test partner extra", + "user_id": self.user.id, + } + ) + all_messages = self._get_mail_messages(extra_partner) + message = all_messages.filtered(lambda x: x.message_type == "user_notification") + self.assertIn("You have been assigned to", message.body) + + def test_partner_write(self): + partner = self.env["res.partner"].create({"name": "Test partner"}) + all_messages = self._get_mail_messages(partner) + partner.write({"user_id": self.user.id}) + new_messages = self._get_mail_messages(partner) - all_messages + # Message with user_notification is created when the assignment email is sent. + self.assertNotIn("user_notification", new_messages.mapped("message_type")) + # Remove model from config parameter (default behavior) + self.icp.value = "" + extra_partner = self.env["res.partner"].create({"name": "Test partner extra"}) + all_messages = self._get_mail_messages(extra_partner) + extra_partner.write({"user_id": self.user.id}) + new_messages = self._get_mail_messages(extra_partner) - all_messages + self.assertIn("You have been assigned to", new_messages.body)