Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] mail_notification_with_history: Migration to 18.0 #1463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions mail_notification_with_history/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
==============================
Mail Notification With History
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6b5e9dc515bb22e90c5642c0882976824bb12382da77b2741ea059a82ee01e63
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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_notification_with_history
: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_notification_with_history
: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|

Followers of a discussion in the chatter of Odoo can be informed by
email of a new message being created. This module adds in that email the
history of the chatter discussion to help the recipient with more
context.

**Table of contents**

.. contents::
:local:

Installation
============

After installing the module its behaviour needs to be activated. This is
done by setting the following class variable
\_mail_notification_include_history to True, on the model that we would
like to activate it.

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_notification_with_history%0Aversion:%2018.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
-------

* Camptocamp

Contributors
------------

- `Camptocamp <https://www.camptocamp.com>`__

- Thierry Ducrest <thierry.ducrest@camptocamp.com>
- Tris Doan <tridm@trobz.com>

Other credits
-------------

The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp.

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-TDu| image:: https://github.com/TDu.png?size=40px
:target: https://github.com/TDu
:alt: TDu

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-TDu|

This module is part of the `OCA/social <https://github.com/OCA/social/tree/18.0/mail_notification_with_history>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_notification_with_history/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions mail_notification_with_history/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Mail Notification With History",
"summary": """Add the previous chatter discussion into new email notifications.""",
"version": "18.0.1.0.0",
"category": "Social Network",
"website": "https://github.com/OCA/social",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["mail"],
"data": ["data/mail_data.xml"],
"development_status": "Beta",
"maintainers": ["TDu"],
}
27 changes: 27 additions & 0 deletions mail_notification_with_history/data/mail_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="mail_notification_with_history.mail_notification_layout"
inherit_id="mail.mail_notification_layout"
>
<xpath expr="//div[@t-out='signature']" position="after">
<t
t-set="message_history"
t-value="message._get_notification_message_history()"
/>
<t t-if="message_history">
<p class="message_history_title">Discussion history in Odoo:</p>
<ul>
<t t-foreach="message_history" t-as="msg">
<li class="message_history_item">
<p><t
t-out="msg.author_id.name or 'unknown'"
/> commented on <span t-field="msg.date" /></p>
<div t-out="msg.body" />
</li>
</t>
</ul>
</t>
</xpath>
</template>
</odoo>
55 changes: 55 additions & 0 deletions mail_notification_with_history/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_notification_with_history
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-28 11:33+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\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: mail_notification_with_history
#: model_terms:ir.ui.view,arch_db:mail_notification_with_history.message_notification_email
msgid "Discussion history in Odoo:"
msgstr "Historial de discusiones en Odoo:"

#. module: mail_notification_with_history
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_message__display_name
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_thread__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: mail_notification_with_history
#: model:ir.model,name:mail_notification_with_history.model_mail_thread
msgid "Email Thread"
msgstr "Hilo de Correo Electrónico"

#. module: mail_notification_with_history
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_message__id
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_thread__id
msgid "ID"
msgstr "ID"

#. module: mail_notification_with_history
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_message____last_update
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_thread____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

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

#. module: mail_notification_with_history
#: model_terms:ir.ui.view,arch_db:mail_notification_with_history.message_notification_email
msgid "commented on"
msgstr "comentado en"
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_notification_with_history
#
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: mail_notification_with_history
#: model_terms:ir.ui.view,arch_db:mail_notification_with_history.message_notification_email
msgid "Discussion history in Odoo:"
msgstr ""

#. module: mail_notification_with_history
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_message__display_name
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_thread__display_name
msgid "Display Name"
msgstr ""

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

#. module: mail_notification_with_history
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_message__id
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_thread__id
msgid "ID"
msgstr ""

#. module: mail_notification_with_history
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_message____last_update
#: model:ir.model.fields,field_description:mail_notification_with_history.field_mail_thread____last_update
msgid "Last Modified on"
msgstr ""

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

#. module: mail_notification_with_history
#: model_terms:ir.ui.view,arch_db:mail_notification_with_history.message_notification_email
msgid "commented on"
msgstr ""
2 changes: 2 additions & 0 deletions mail_notification_with_history/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
31 changes: 31 additions & 0 deletions mail_notification_with_history/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models


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

def _get_notification_message_history(self):
"""Get the list of messages to include into an email notification history."""
if (
not self.model
or not self.env[self.model]._mail_notification_include_history
):
return self.browse()
domain = self._get_notification_message_history_domain()
messages = self.env["mail.message"].search(domain, order="date desc")
return messages - self

def _get_notification_message_history_domain(self):
"""Return the domain for email and send message comments."""
return [
("model", "=", self.model),
("res_id", "=", self.res_id),
"|",
"&",
("message_type", "=", "comment"),
("subtype_id", "=", self.env.ref("mail.mt_comment").id),
("message_type", "=", "email"),
]
10 changes: 10 additions & 0 deletions mail_notification_with_history/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models


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

_mail_notification_include_history = False
3 changes: 3 additions & 0 deletions mail_notification_with_history/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions mail_notification_with_history/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Camptocamp](https://www.camptocamp.com)

> - Thierry Ducrest \<<thierry.ducrest@camptocamp.com>\>
> - Tris Doan \<<tridm@trobz.com>\>
1 change: 1 addition & 0 deletions mail_notification_with_history/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp.
4 changes: 4 additions & 0 deletions mail_notification_with_history/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Followers of a discussion in the chatter of Odoo can be informed by
email of a new message being created. This module adds in that email the
history of the chatter discussion to help the recipient with more
context.
4 changes: 4 additions & 0 deletions mail_notification_with_history/readme/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
After installing the module its behaviour needs to be activated. This is
done by setting the following class variable
\_mail_notification_include_history to True, on the model that we would
like to activate it.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading