diff --git a/mail_optional_follower_notification/README.rst b/mail_optional_follower_notification/README.rst new file mode 100644 index 0000000000..c05f910a6c --- /dev/null +++ b/mail_optional_follower_notification/README.rst @@ -0,0 +1,96 @@ +=================================== +Mail optional follower notification +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9c68e71c93b147a204c464690db84ee1cfa58d034efb80a3eb83f8c5644c35d4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/mail_optional_follower_notification + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-18-0/social-18-0-mail_optional_follower_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/social&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the possibility to choose if you want to automatically +notify followers on mail.compose.message. By default, Odoo notify +automatically all followers. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to use the checkbox near "Followers of the +document and" on mail.compose.message: + +This field it's initialized to true to keep the standard behavior. + +|image1| + +|image2| + +.. |image1| image:: https://raw.githubusercontent.com/OCA/social/18.0/mail_optional_follower_notification/static/description/optional_follower_001.png +.. |image2| image:: https://raw.githubusercontent.com/OCA/social/18.0/mail_optional_follower_notification/static/description/optional_follower_002.png + +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 +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Adrien Peiffer +- Laurent Mignon +- Andrea Stirpe +- Robin Goots + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_optional_follower_notification/__init__.py b/mail_optional_follower_notification/__init__.py new file mode 100644 index 0000000000..9b4296142f --- /dev/null +++ b/mail_optional_follower_notification/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/mail_optional_follower_notification/__manifest__.py b/mail_optional_follower_notification/__manifest__.py new file mode 100644 index 0000000000..860a4f4447 --- /dev/null +++ b/mail_optional_follower_notification/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Mail optional follower notification", + "summary": "Choose to notify followers on mail.compose.message", + "author": "ACSONE SA/NV," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "category": "Social Network", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "depends": ["mail"], + "data": ["wizard/mail_compose_message_view.xml"], +} diff --git a/mail_optional_follower_notification/i18n/am.po b/mail_optional_follower_notification/i18n/am.po new file mode 100644 index 0000000000..0a3ce02b62 --- /dev/null +++ b/mail_optional_follower_notification/i18n/am.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-17 01:02+0000\n" +"PO-Revision-Date: 2017-05-17 01:02+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Amharic (https://www.transifex.com/oca/teams/23907/am/)\n" +"Language: am\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" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Partner" +#~ msgstr "ተባባሪ" diff --git a/mail_optional_follower_notification/i18n/ar.po b/mail_optional_follower_notification/i18n/ar.po new file mode 100644 index 0000000000..cb01dc3155 --- /dev/null +++ b/mail_optional_follower_notification/i18n/ar.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-17 01:02+0000\n" +"PO-Revision-Date: 2017-05-17 01:02+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Arabic (https://www.transifex.com/oca/teams/23907/ar/)\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Partner" +#~ msgstr "الشريك" diff --git a/mail_optional_follower_notification/i18n/bg.po b/mail_optional_follower_notification/i18n/bg.po new file mode 100644 index 0000000000..f47381140f --- /dev/null +++ b/mail_optional_follower_notification/i18n/bg.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-16 03:47+0000\n" +"PO-Revision-Date: 2018-01-16 03:47+0000\n" +"Last-Translator: OCA Transbot , 2018\n" +"Language-Team: Bulgarian (https://www.transifex.com/oca/teams/23907/bg/)\n" +"Language: bg\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" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Partner" +#~ msgstr "Партньор" diff --git a/mail_optional_follower_notification/i18n/bs.po b/mail_optional_follower_notification/i18n/bs.po new file mode 100644 index 0000000000..8a2f52b8f8 --- /dev/null +++ b/mail_optional_follower_notification/i18n/bs.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-17 01:02+0000\n" +"PO-Revision-Date: 2017-05-17 01:02+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Bosnian (https://www.transifex.com/oca/teams/23907/bs/)\n" +"Language: bs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Partner" +#~ msgstr "Partner" diff --git a/mail_optional_follower_notification/i18n/ca.po b/mail_optional_follower_notification/i18n/ca.po new file mode 100644 index 0000000000..d47bf18ec0 --- /dev/null +++ b/mail_optional_follower_notification/i18n/ca.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-17 01:02+0000\n" +"PO-Revision-Date: 2017-05-17 01:02+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\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" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistent per composició de correus electrònics" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Message" +#~ msgstr "Missatge" + +#~ msgid "Partner" +#~ msgstr "Empresa" diff --git a/mail_optional_follower_notification/i18n/cs.po b/mail_optional_follower_notification/i18n/cs.po new file mode 100644 index 0000000000..edd713dbf8 --- /dev/null +++ b/mail_optional_follower_notification/i18n/cs.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-17 01:02+0000\n" +"PO-Revision-Date: 2017-05-17 01:02+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Czech (https://www.transifex.com/oca/teams/23907/cs/)\n" +"Language: cs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Partner" +#~ msgstr "Společník" diff --git a/mail_optional_follower_notification/i18n/da.po b/mail_optional_follower_notification/i18n/da.po new file mode 100644 index 0000000000..d84337ba95 --- /dev/null +++ b/mail_optional_follower_notification/i18n/da.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-17 01:02+0000\n" +"PO-Revision-Date: 2017-05-17 01:02+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Danish (https://www.transifex.com/oca/teams/23907/da/)\n" +"Language: da\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" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +msgid "Notify Followers" +msgstr "" + +#~ msgid "Partner" +#~ msgstr "Partner" diff --git a/mail_optional_follower_notification/i18n/de.po b/mail_optional_follower_notification/i18n/de.po new file mode 100644 index 0000000000..da9a5b288a --- /dev/null +++ b/mail_optional_follower_notification/i18n/de.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_optional_follower_notification +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-16 03:47+0000\n" +"PO-Revision-Date: 2018-12-15 14:58+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\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 3.3\n" + +#. module: mail_optional_follower_notification +#: model_terms:ir.ui.view,arch_db:mail_optional_follower_notification.email_compose_message_wizard_form +msgid "" +" - Warning : Followers will not be notified but they " +"can access the notification directly from the document (if they are allowed " +"to)" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_thread +msgid "Email Thread" +msgstr "" + +#. module: mail_optional_follower_notification +#: model:ir.model,name:mail_optional_follower_notification.model_mail_compose_message +msgid "Email composition wizard" +msgstr "Assistent zum Email verfassen" + +#. module: mail_optional_follower_notification +#: model:ir.model.fields,field_description:mail_optional_follower_notification.field_mail_compose_message__notify_followers +#, fuzzy +msgid "Notify Followers" +msgstr "Abonnenten benachrichtigen" + +#, fuzzy +#~ msgid "" +#~ "\n" +#~ " + + + + +Mail optional follower notification + + + +
+

Mail optional follower notification

+ + +

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

+

This module adds the possibility to choose if you want to automatically +notify followers on mail.compose.message. By default, Odoo notify +automatically all followers.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to use the checkbox near “Followers of the +document and” on mail.compose.message:

+

This field it’s initialized to true to keep the standard behavior.

+

image1

+

image2

+
+
+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/mail_optional_follower_notification/static/description/optional_follower_001.png b/mail_optional_follower_notification/static/description/optional_follower_001.png new file mode 100644 index 0000000000..897e596cfe Binary files /dev/null and b/mail_optional_follower_notification/static/description/optional_follower_001.png differ diff --git a/mail_optional_follower_notification/static/description/optional_follower_002.png b/mail_optional_follower_notification/static/description/optional_follower_002.png new file mode 100644 index 0000000000..24d9d9756f Binary files /dev/null and b/mail_optional_follower_notification/static/description/optional_follower_002.png differ diff --git a/mail_optional_follower_notification/tests/__init__.py b/mail_optional_follower_notification/tests/__init__.py new file mode 100644 index 0000000000..b58d6f27f3 --- /dev/null +++ b/mail_optional_follower_notification/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_optional_follower_notifications diff --git a/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py b/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py new file mode 100644 index 0000000000..011e8247d3 --- /dev/null +++ b/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py @@ -0,0 +1,90 @@ +# Copyright 2019 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.fields import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestMailOptionalFollowernotifications(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_obj = cls.env["res.partner"] + cls.partner_01 = cls.env.ref("base.res_partner_2") + demo_user = cls.env.ref("base.user_demo") + cls.partner_follower = demo_user.partner_id + cls.partner_no_follower = demo_user.copy().partner_id + cls.partner_no_follower.email = "test@example.com" + cls.partner_01.message_subscribe(partner_ids=[cls.partner_follower.id]) + ctx = cls.env.context.copy() + ctx.update( + { + "default_model": "res.partner", + "default_res_ids": [cls.partner_01.id], + "default_composition_mode": "comment", + } + ) + cls.mail_compose_context = ctx + cls.MailCompose = cls.env["mail.compose.message"] + + def _send_mail(self, recipients, notify_followers): + old_messages = self.env["mail.message"].search([]) + values = { + "subject": "Your subject here", + "body": "Your plain text body here", + "partner_ids": [Command.set(recipients.ids)], + "notify_followers": notify_followers, + } + composer = self.MailCompose.with_context(**self.mail_compose_context).create( + values + ) + composer.action_send_mail() + return self.env["mail.message"].search([]) - old_messages + + def test_1(self): + """ + Data: + One partner follower of partner_01 + Test case: + Send message to the follower and a non follower partner + Expected result: + Both are notified + """ + message = self._send_mail( + self.partner_follower + self.partner_no_follower, notify_followers=True + ) + self.assertEqual( + message.notification_ids.mapped("res_partner_id"), + self.partner_no_follower + self.partner_follower, + ) + + def test_2(self): + """ + Data: + One partner follower of partner_01 + Test case: + Send message to the non follower partner + Expected result: + Both are notified + """ + message = self._send_mail(self.partner_no_follower, notify_followers=True) + self.assertEqual( + message.notification_ids.mapped("res_partner_id"), + self.partner_no_follower + self.partner_follower, + ) + + def test_3(self): + """ + Data: + One partner follower of partner_01 + Test case: + Send message to the non follower partner and disable the + notification to followers + Expected result: + Only the non follower partner is notified + """ + message = self._send_mail(self.partner_no_follower, notify_followers=False) + self.assertEqual( + message.notification_ids.mapped("res_partner_id"), self.partner_no_follower + ) diff --git a/mail_optional_follower_notification/wizard/__init__.py b/mail_optional_follower_notification/wizard/__init__.py new file mode 100644 index 0000000000..2d9c29a8b1 --- /dev/null +++ b/mail_optional_follower_notification/wizard/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import mail_compose_message diff --git a/mail_optional_follower_notification/wizard/mail_compose_message.py b/mail_optional_follower_notification/wizard/mail_compose_message.py new file mode 100644 index 0000000000..0cd83ec37e --- /dev/null +++ b/mail_optional_follower_notification/wizard/mail_compose_message.py @@ -0,0 +1,24 @@ +# Copyright 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MailComposeMessage(models.TransientModel): + _inherit = "mail.compose.message" + + notify_followers = fields.Boolean(default=True) + + def _action_send_mail(self, auto_commit=False): + result_mails_su, result_messages = ( + self.env["mail.mail"].sudo(), + self.env["mail.message"], + ) + for wizard in self: + wizard = wizard.with_context(notify_followers=wizard.notify_followers) + res_mail, res_message = super(MailComposeMessage, wizard)._action_send_mail( + auto_commit=auto_commit + ) + result_mails_su += res_mail + result_messages += res_message + return result_mails_su, result_messages diff --git a/mail_optional_follower_notification/wizard/mail_compose_message_view.xml b/mail_optional_follower_notification/wizard/mail_compose_message_view.xml new file mode 100644 index 0000000000..baea0d92ba --- /dev/null +++ b/mail_optional_follower_notification/wizard/mail_compose_message_view.xml @@ -0,0 +1,28 @@ + + + + mail.compose.message + + + + + + + - Warning : Followers will not be notified but they can access the notification directly from the document (if they are allowed to) + + + +