Skip to content

Commit

Permalink
[ADD] mail_forward: new module to forward messages from the chatter
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-lopez-tecnativa committed Oct 2, 2024
1 parent 1355ecf commit f1cce86
Show file tree
Hide file tree
Showing 23 changed files with 1,155 additions and 0 deletions.
90 changes: 90 additions & 0 deletions mail_forward/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
====================
Mail Forward Message
====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dd21150507ec3adfe337e04f08c50127d7ecd7644dde4d56e77ce0ba6723ddd0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/15.0/mail_forward
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_forward
: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=15.0
:alt: Try me on Runboat

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

This module allows users to forward messages from the chatter of any document to other users,
adding them as followers of the document without notifying the current followers.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, follow these steps:

* Navigate to the chatter of any document.
* Hover the mouse over any message in the chatter (excluding internal notes).
* A Forward icon will appear next to the message.
* Click the button to display a wizard with the message.
* Select the users to forward the message to.
* Click the 'Send Mail' button to send the message to the selected users.

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

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

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:
* Carlos López

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 <https://github.com/OCA/social/tree/15.0/mail_forward>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions mail_forward/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
27 changes: 27 additions & 0 deletions mail_forward/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Tecnativa - Carlos Lopez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Mail Forward Message",
"version": "15.0.1.0.0",
"summary": "Forward messages from the chatter of any document to other users.",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"depends": ["mail", "contacts"],
"data": [
"wizards/mail_compose_message_view.xml",
],
"assets": {
"web.assets_backend": [
"mail_forward/static/src/components/**/*.esm.js",
],
"web.assets_qweb": [
"mail_forward/static/src/components/*/*.xml",
],
"web.assets_tests": [
"mail_forward/static/tests/tours/**/*",
],
},
"installable": True,
"auto_install": False,
"license": "AGPL-3",
}
83 changes: 83 additions & 0 deletions mail_forward/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_forward
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-02 12:25+0000\n"
"PO-Revision-Date: 2024-10-02 07:27-0500\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: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "---------- Forwarded message ---------"
msgstr "---------- Mensaje reenviado ---------"

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "Date"
msgstr "Fecha"

#. module: mail_forward
#: model:ir.model,name:mail_forward.model_mail_thread
msgid "Email Thread"
msgstr "Hilo de correos electrónicos"

#. module: mail_forward
#: model:ir.model,name:mail_forward.model_mail_compose_message
msgid "Email composition wizard"
msgstr "Asistente de composición de correos electrónicos"

#. module: mail_forward
#. openerp-web
#: code:addons/mail_forward/models/mail_message.py:0
#: code:addons/mail_forward/static/src/components/forward_message/forward_message.xml:0
#, python-format
msgid "Forward Message"
msgstr "Reenviar mensaje"

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "From"
msgstr "De"

#. module: mail_forward
#: code:addons/mail_forward/wizards/mail_compose_message.py:0
#, python-format
msgid "Fwd:"
msgstr ""

#. module: mail_forward
#: model:ir.model,name:mail_forward.model_mail_message
msgid "Message"
msgstr "Mensaje"

#. module: mail_forward
#: code:addons/mail_forward/wizards/mail_compose_message.py:0
#, python-format
msgid "Re:"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "Subject"
msgstr "Asunto"

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "To"
msgstr "Para"
82 changes: 82 additions & 0 deletions mail_forward/i18n/mail_forward.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_forward
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-02 12:25+0000\n"
"PO-Revision-Date: 2024-10-02 12:25+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_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "---------- Forwarded message ---------"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "Date"
msgstr ""

#. module: mail_forward
#: model:ir.model,name:mail_forward.model_mail_thread
msgid "Email Thread"
msgstr ""

#. module: mail_forward
#: model:ir.model,name:mail_forward.model_mail_compose_message
msgid "Email composition wizard"
msgstr ""

#. module: mail_forward
#. openerp-web
#: code:addons/mail_forward/models/mail_message.py:0
#: code:addons/mail_forward/static/src/components/forward_message/forward_message.xml:0
#: code:addons/mail_forward/static/src/components/forward_message/forward_message.xml:0
#, python-format
msgid "Forward Message"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "From"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/wizards/mail_compose_message.py:0
#, python-format
msgid "Fwd:"
msgstr ""

#. module: mail_forward
#: model:ir.model,name:mail_forward.model_mail_message
msgid "Message"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/wizards/mail_compose_message.py:0
#, python-format
msgid "Re:"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "Subject"
msgstr ""

#. module: mail_forward
#: code:addons/mail_forward/models/mail_message.py:0
#, python-format
msgid "To"
msgstr ""
2 changes: 2 additions & 0 deletions mail_forward/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mail_message
from . import mail_thread
57 changes: 57 additions & 0 deletions mail_forward/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2024 Tecnativa - Carlos Lopez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, models
from odoo.tools import format_datetime


class MailMessage(models.Model):
_inherit = "mail.message"

def action_wizard_forward(self):
view = self.env.ref("mail_forward.mail_compose_message_forward_form")
action = self.env["ir.actions.actions"]._for_xml_id(
"mail.action_email_compose_message_wizard"
)
action["name"] = _("Forward Message")
action["view_mode"] = view.type
action["views"] = [(view.id, view.type)]
action["context"] = {
"default_model": self.model,
"default_res_id": self.res_id,
"default_composition_mode": "comment",
"default_body": self._build_message_body_for_forward(),
"default_attachment_ids": self.attachment_ids.ids,
"default_is_log": False,
"default_notify": True,
"force_email": True,
"message_forwarded_id": self.id,
}
return action

def _build_message_body_for_forward(self):
partner_emails = [
partner.email_formatted
for partner in self.partner_ids
if partner.email_formatted
]
return """
<br/><br/><br/>
{str_forwarded_message}<br/>
{str_from}: {email_from}<br/>
{str_date}: {date}<br/>
{str_subject}: {subject}<br/>
{str_to}: {to}<br/>
<br/><br/>
{body}
""".format(
str_forwarded_message=_("---------- Forwarded message ---------"),
email_from=self.email_from,
date=format_datetime(self.env, self.date),
subject=self.subject,
to=", ".join(partner_emails),
str_date=_("Date"),
str_subject=_("Subject"),
str_from=_("From"),
str_to=_("To"),
body=self.body,
)
19 changes: 19 additions & 0 deletions mail_forward/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Tecnativa - Carlos Lopez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models


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

def _notify_compute_recipients(self, message, msg_vals):
recipients_data = super()._notify_compute_recipients(message, msg_vals)
# only notify to explicit partners, remove others(followers).
if self.env.context.get("message_forwarded_id"):
current_partners_ids = message.partner_ids.ids
new_recipeints = []
for recipeint in recipients_data:
if recipeint["id"] in current_partners_ids:
new_recipeints.append(recipeint)
recipients_data = new_recipeints
return recipients_data
2 changes: 2 additions & 0 deletions mail_forward/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Carlos López
2 changes: 2 additions & 0 deletions mail_forward/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows users to forward messages from the chatter of any document to other users,
adding them as followers of the document without notifying the current followers.
8 changes: 8 additions & 0 deletions mail_forward/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To use this module, follow these steps:

* Navigate to the chatter of any document.
* Hover the mouse over any message in the chatter (excluding internal notes).
* A Forward icon will appear next to the message.
* Click the button to display a wizard with the message.
* Select the users to forward the message to.
* Click the 'Send Mail' button to send the message to the selected users.
Loading

0 comments on commit f1cce86

Please sign in to comment.