forked from Vauxoo/addons-vauxoo
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from Vauxoo/15.0
Syncing from upstream Vauxoo/addons-vauxoo (15.0)
- Loading branch information
Showing
16 changed files
with
223 additions
and
0 deletions.
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,60 @@ | ||
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg | ||
:alt: License: LGPL-3 | ||
|
||
Mail Channel Notify Tag | ||
======================= | ||
|
||
This module re-enables sending messages to channels and their members | ||
when the channels are mentioned in the messages of the records. | ||
|
||
Message in the record: | ||
|
||
.. image:: ../mail_channel_notify_tag/static/description/record.png | ||
:alt: Message in the record | ||
:width: 1200px | ||
|
||
Message in the channel: | ||
|
||
.. image:: ../mail_channel_notify_tag/static/description/channel.png | ||
:alt: Message in the channel | ||
:width: 1200px | ||
|
||
Email: | ||
|
||
.. image:: ../mail_channel_notify_tag/static/description/email.png | ||
:alt: Email | ||
:width: 1200px | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/Vauxoo/addons-vauxoo/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 | ||
<https://github.com/vauxoo/ | ||
addons-vauxoo/issues/new?body=module:%20 | ||
mail_channel_notify_tag%0Aversion:%20 | ||
15.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Luis González <[email protected]> | ||
* Rolando Duarte <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://www.vauxoo.com/logo.png | ||
:alt: Vauxoo | ||
:target: https://vauxoo.com | ||
|
||
This module is maintained by Vauxoo. | ||
|
||
A latinamerican company that provides training, coaching, | ||
development and implementation of enterprise management | ||
systems and bases its entire operation strategy in the use | ||
of Open Source Software and its main product is odoo. | ||
|
||
To contribute to this module, please visit https://www.vauxoo.com. |
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 controllers | ||
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,27 @@ | ||
{ | ||
"name": "Mail Channel Notify Tag", | ||
"summary": "Module to notify the channels when they are mentioned in the chatter", | ||
"author": "Vauxoo", | ||
"website": "https://www.vauxoo.com", | ||
"license": "LGPL-3", | ||
"category": "Productivity/Discuss", | ||
"version": "15.0.1.0.0", | ||
"depends": [ | ||
"mail", | ||
], | ||
"data": [ | ||
"views/mail_templates.xml", | ||
], | ||
"demo": [], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"mail_channel_notify_tag/static/src/models/composer_view/composer_view.esm.js", | ||
], | ||
"mail.assets_discuss_public": [ | ||
"mail_channel_notify_tag/static/src/models/composer_view/composer_view.esm.js", | ||
], | ||
}, | ||
"installable": True, | ||
"auto_install": False, | ||
"application": False, | ||
} |
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 discuss |
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,7 @@ | ||
from odoo.addons.mail.controllers.discuss import DiscussController | ||
|
||
|
||
class DiscussChannel(DiscussController): | ||
def _get_allowed_message_post_params(self): | ||
"""composer is passing channel_ids again, it is required to allow it to be available in message_post""" | ||
return super()._get_allowed_message_post_params() | {"channel_ids"} |
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,31 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mail_channel_notify_tag | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-09-20 02:08+0000\n" | ||
"PO-Revision-Date: 2023-09-20 02:08+0000\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_channel_notify_tag | ||
#: model:ir.model,name:mail_channel_notify_tag.model_mail_followers | ||
msgid "Document Followers" | ||
msgstr "Seguidores del documento" | ||
|
||
#. module: mail_channel_notify_tag | ||
#: model:ir.model,name:mail_channel_notify_tag.model_mail_thread | ||
msgid "Email Thread" | ||
msgstr "Hilo de mensajes" | ||
|
||
#. module: mail_channel_notify_tag | ||
#: model_terms:ir.ui.view,arch_db:mail_channel_notify_tag.mail_channel_message_repost | ||
msgid "on" | ||
msgstr "en" |
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 mail_followers | ||
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,14 @@ | ||
from odoo import models | ||
|
||
|
||
class MailFollowers(models.Model): | ||
_inherit = "mail.followers" | ||
|
||
def _get_recipient_data(self, records, message_type, subtype_id, pids=None): | ||
"""Inheritance to take into account the partners from the channels to notify them by email""" | ||
channel_ids = self.env.context.get("mentioned_channel_ids") | ||
if pids is None: | ||
pids = set() | ||
if channel_ids: | ||
pids |= set(self.env["mail.channel"].sudo().browse(channel_ids).channel_partner_ids.ids) | ||
return super()._get_recipient_data(records, message_type, subtype_id, pids) |
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,24 @@ | ||
from odoo import api, models | ||
|
||
|
||
class MailThread(models.AbstractModel): | ||
_inherit = "mail.thread" | ||
|
||
def _notify_channels_from_messages(self, message, **kwargs): | ||
channel_ids = self.env.context.get("mentioned_channel_ids") | ||
if not channel_ids: | ||
return | ||
kwargs.pop("partner_ids", []) # Remove target partners to not send duplicate messages. | ||
subtype_xmlid = kwargs.pop("subtype_xmlid", None) | ||
if subtype_xmlid: | ||
kwargs["subtype_id"] = self.env.ref(subtype_xmlid).id | ||
template = self.env.ref("mail_channel_notify_tag.mail_channel_message_repost") | ||
values = {"message": message, "source": self} | ||
self.env["mail.channel"].sudo().browse(channel_ids).message_post_with_view(template, values=values, **kwargs) | ||
|
||
@api.returns("mail.message", lambda value: value.id) | ||
def message_post(self, *, body="", **kwargs): | ||
self = self.with_context(mentioned_channel_ids=kwargs.pop("channel_ids", [])) | ||
message = super().message_post(body=body, **kwargs) | ||
self._notify_channels_from_messages(message, **kwargs) | ||
return message |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
mail_channel_notify_tag/static/src/models/composer_view/composer_view.esm.js
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,15 @@ | ||
/** @odoo-module **/ | ||
|
||
import {registerInstancePatchModel} from "@mail/model/model_core"; | ||
|
||
registerInstancePatchModel("mail.composer_view", "mail_channel_notify_tag", { | ||
/** | ||
* @override | ||
*/ | ||
_getMessageData() { | ||
return { | ||
...this._super(...arguments), | ||
channel_ids: this.composer.mentionedChannels.map((channel) => channel.id), | ||
}; | ||
}, | ||
}); |
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 test_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,20 @@ | ||
from odoo.tests import TransactionCase, tagged | ||
|
||
|
||
@tagged("mail_thread") | ||
class TestMailThread(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.channel = cls.env.ref("mail.channel_1") | ||
cls.partner = cls.env.user.partner_id | ||
|
||
def test_01_message_post(self): | ||
self.partner.message_post(subject="Test Channel IDs", body="Test Message") | ||
msg = self.channel.message_ids[0] | ||
self.assertNotEqual(msg.subject, "Test Channel IDs") | ||
self.assertNotIn("Test Message", msg.body) | ||
self.partner.message_post(subject="Test Channel IDs", body="Test Message", channel_ids=self.channel.ids) | ||
msg = self.channel.message_ids[0] | ||
self.assertEqual(msg.subject, "Test Channel IDs") | ||
self.assertIn("Test Message", msg.body) |
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
|
||
<template id="mail_channel_message_repost" name="Mail Channel Message Repost"> | ||
<div style="width: 100%; margin: 0 auto;"> | ||
<div style="font-size: 0.8em;margin: 5px 0;"> | ||
on | ||
<a | ||
t-attf-href="/web#id={{source.id}}&model={{source._name}}&view_type=form" | ||
target="_blank" | ||
t-out="source.display_name" | ||
/> | ||
</div> | ||
<br /> | ||
<div t-out="message.body" /> | ||
</div> | ||
</template> | ||
|
||
</odoo> |