diff --git a/setup/web_notify_channel_message/odoo/addons/web_notify_channel_message b/setup/web_notify_channel_message/odoo/addons/web_notify_channel_message new file mode 120000 index 000000000..2f4f9a844 --- /dev/null +++ b/setup/web_notify_channel_message/odoo/addons/web_notify_channel_message @@ -0,0 +1 @@ +../../../../web_notify_channel_message \ No newline at end of file diff --git a/setup/web_notify_channel_message/setup.py b/setup/web_notify_channel_message/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_notify_channel_message/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_notify_channel_message/README.rst b/web_notify_channel_message/README.rst new file mode 100644 index 000000000..0e31d818b --- /dev/null +++ b/web_notify_channel_message/README.rst @@ -0,0 +1,81 @@ +========================== +Web Notify Channel Message +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/14.0/web_notify_channel_message + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_notify_channel_message + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module will send an instant notifications to all users of a channel when a new message has been posted. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Joan Sisquella +* Thiago Mulero +* David Jimenez +* Jordi Ballester + +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/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_notify_channel_message/__init__.py b/web_notify_channel_message/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/web_notify_channel_message/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_notify_channel_message/__manifest__.py b/web_notify_channel_message/__manifest__.py new file mode 100644 index 000000000..050c2d74e --- /dev/null +++ b/web_notify_channel_message/__manifest__.py @@ -0,0 +1,16 @@ +# pylint: disable=missing-docstring +# Copyright 2023 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Web Notify Channel Message", + "summary": """ + Send an instant notification to channel users when a new message is posted""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "development_status": "Alpha", + "website": "https://github.com/OCA/web", + "depends": ["web_notify", "mail"], + "installable": True, +} diff --git a/web_notify_channel_message/i18n/fr.po b/web_notify_channel_message/i18n/fr.po new file mode 100644 index 000000000..b0cdf7ee6 --- /dev/null +++ b/web_notify_channel_message/i18n/fr.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_notify_channel_message +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-11 00:11+0000\n" +"Last-Translator: Claude R Perrin \n" +"Language-Team: none\n" +"Language: fr\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 4.17\n" + +#. module: web_notify_channel_message +#: model:ir.model,name:web_notify_channel_message.model_mail_channel +msgid "Discussion Channel" +msgstr "Canal de discussion" + +#. module: web_notify_channel_message +#: model:ir.model.fields,field_description:web_notify_channel_message.field_mail_channel__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: web_notify_channel_message +#: model:ir.model.fields,field_description:web_notify_channel_message.field_mail_channel__id +msgid "ID" +msgstr "ID" + +#. module: web_notify_channel_message +#: model:ir.model.fields,field_description:web_notify_channel_message.field_mail_channel____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: web_notify_channel_message +#: code:addons/web_notify_channel_message/models/mail_channel.py:0 +#, python-format +msgid "You have a new message in channel %s" +msgstr "Vous avez un nouveau message dans le canal %s" diff --git a/web_notify_channel_message/i18n/web_notify_channel_message.pot b/web_notify_channel_message/i18n/web_notify_channel_message.pot new file mode 100644 index 000000000..01dbb9502 --- /dev/null +++ b/web_notify_channel_message/i18n/web_notify_channel_message.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_notify_channel_message +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: web_notify_channel_message +#: model:ir.model,name:web_notify_channel_message.model_mail_channel +msgid "Discussion Channel" +msgstr "" + +#. module: web_notify_channel_message +#: model:ir.model.fields,field_description:web_notify_channel_message.field_mail_channel__display_name +msgid "Display Name" +msgstr "" + +#. module: web_notify_channel_message +#: model:ir.model.fields,field_description:web_notify_channel_message.field_mail_channel__id +msgid "ID" +msgstr "" + +#. module: web_notify_channel_message +#: model:ir.model.fields,field_description:web_notify_channel_message.field_mail_channel____last_update +msgid "Last Modified on" +msgstr "" + +#. module: web_notify_channel_message +#: code:addons/web_notify_channel_message/models/mail_channel.py:0 +#, python-format +msgid "You have a new message in channel %s" +msgstr "" diff --git a/web_notify_channel_message/models/__init__.py b/web_notify_channel_message/models/__init__.py new file mode 100644 index 000000000..3ce7ca7fe --- /dev/null +++ b/web_notify_channel_message/models/__init__.py @@ -0,0 +1 @@ +from . import mail_channel diff --git a/web_notify_channel_message/models/mail_channel.py b/web_notify_channel_message/models/mail_channel.py new file mode 100644 index 000000000..ce1c55772 --- /dev/null +++ b/web_notify_channel_message/models/mail_channel.py @@ -0,0 +1,21 @@ +# pylint: disable=missing-docstring +# Copyright 2016 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, models + + +class MailChannel(models.Model): + _inherit = "mail.channel" + + def message_post(self, *, message_type="notification", **kwargs): + message = super().message_post(message_type=message_type, **kwargs) + for partner in self.channel_partner_ids: + users = partner.user_ids + for user in users: + if user in message.author_id.user_ids: + continue + user.notify_info( + message=_("You have a new message in channel %s") % self.name + ) + return message diff --git a/web_notify_channel_message/readme/CONTRIBUTORS.rst b/web_notify_channel_message/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..56ac1356f --- /dev/null +++ b/web_notify_channel_message/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Joan Sisquella +* Thiago Mulero +* David Jimenez +* Jordi Ballester diff --git a/web_notify_channel_message/readme/DESCRIPTION.rst b/web_notify_channel_message/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ddb6ae81f --- /dev/null +++ b/web_notify_channel_message/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module will send an instant notifications to all users of a channel when a new message has been posted. diff --git a/web_notify_channel_message/static/description/icon.png b/web_notify_channel_message/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_notify_channel_message/static/description/icon.png differ diff --git a/web_notify_channel_message/static/description/index.html b/web_notify_channel_message/static/description/index.html new file mode 100644 index 000000000..faa63cf82 --- /dev/null +++ b/web_notify_channel_message/static/description/index.html @@ -0,0 +1,428 @@ + + + + + + +Web Notify Channel Message + + + +
+

Web Notify Channel Message

+ + +

Alpha License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

This module will send an instant notifications to all users of a channel when a new message has been posted.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

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/web project on GitHub.

+

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

+
+
+
+ + diff --git a/web_notify_channel_message/tests/__init__.py b/web_notify_channel_message/tests/__init__.py new file mode 100644 index 000000000..8c59b263e --- /dev/null +++ b/web_notify_channel_message/tests/__init__.py @@ -0,0 +1 @@ +from . import test_notify_channel_message diff --git a/web_notify_channel_message/tests/test_notify_channel_message.py b/web_notify_channel_message/tests/test_notify_channel_message.py new file mode 100644 index 000000000..edaec369c --- /dev/null +++ b/web_notify_channel_message/tests/test_notify_channel_message.py @@ -0,0 +1,51 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import api +from odoo.tests import common + + +class TestWebNotifyChannelMessage(common.TransactionCase): + @classmethod + def setUpClass(cls): + super(TestWebNotifyChannelMessage, cls).setUpClass() + cls.env.user = cls.env.ref("base.user_admin") + cls.env = api.Environment(cls.cr, cls.env.user.id, {}) + cls.env.user.tz = False # Make sure there's no timezone in user + cls.user_internal = cls.env["res.users"].create( + { + "name": "Test Internal User", + "login": "internal_user", + "password": "internal_user", + "email": "mark.brown23@example.com", + } + ) + cls.channel = cls.env["mail.channel"].create( + { + "name": "Test channel", + "channel_partner_ids": [ + (4, cls.env.user.partner_id.id), + (4, cls.user_internal.partner_id.id), + ], + } + ) + + def test_01_post_message(self): + initial_message = ( + self.env["mail.channel"] + .search([("name", "=", "Test channel")], limit=1) + .message_ids + ) + self.assertEqual(len(initial_message), 0) + self.channel.message_post( + author_id=self.env.user.partner_id.id, + body="Hello", + message_type="notification", + subtype_xmlid="mail.mt_comment", + ) + message = ( + self.env["mail.channel"] + .search([("name", "=", "Test channel")], limit=1) + .message_ids[0] + ) + self.assertEqual(len(message), 1)