diff --git a/smile_partner_mail_history/README.rst b/smile_partner_mail_history/README.rst new file mode 100644 index 00000000..f54b148a --- /dev/null +++ b/smile_partner_mail_history/README.rst @@ -0,0 +1,76 @@ +=========================== +Smile Partner Mail History +=========================== + +.. |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-Smile_SA%2Fodoo_addons-lightgray.png?logo=github + :target: https://github.com/Smile-SA/odoo_addons/tree/13.0/smile_partner_mail_history + :alt: Smile-SA/odoo_addons + +|badge2| |badge3| + +This module allows you to consult all partner's received messages (Emails, Chatter Notifications ...) through his form view. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Go to a partner `Form` view and click on smart button `History`. + +.. figure:: static/description/partner_form.png + :alt: Import + :width: 100% + +2. You will be redirected to partner's received messages. + +.. figure:: static/description/messages.png + :alt: Import + :width: 100% + +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 +`here `_. + +GDPR / EU Privacy +================= + +This addons does not collect any data and does not set any browser cookies. + +Credits +======= + +Authors +~~~~~~~ + +* Smile SA + +Contributors +~~~~~~~~~~~~ + +* Isabelle RICHARD +* Seif Iddine HAMMAMI + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the Smile SA. + +Since 1991 Smile has been a pioneer of technology and also the European expert in open source solutions. + +.. image:: https://avatars0.githubusercontent.com/u/572339?s=200&v=4 + :alt: Smile SA + :target: http://smile.fr + +This module is part of the `odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/smile_partner_mail_history/__init__.py b/smile_partner_mail_history/__init__.py new file mode 100644 index 00000000..83aed83d --- /dev/null +++ b/smile_partner_mail_history/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (C) 2020 Smile () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/smile_partner_mail_history/__manifest__.py b/smile_partner_mail_history/__manifest__.py new file mode 100644 index 00000000..35888147 --- /dev/null +++ b/smile_partner_mail_history/__manifest__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# (C) 2020 Smile () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Smile Partner Mail History", + "version": "17.0.0.1.0", + "depends": [ + "web", + "mail", + ], + "author": "Smile", + "license": 'AGPL-3', + "description": "Consult Received Emails From Partner Form", + "summary": "", + "website": "", + "category": "Discuss", + "data": [ + # Security + # Data + # Reports + # Views + 'views/mail_message_views.xml', + 'views/res_partner_views.xml', + # Wizard + ], + "demo": [ + ], + "qweb": [ + ], + "assets": { + "web.assets_backend": [ + 'smile_partner_mail_history/static/src/scss/partner_mail_history.scss', + ], + }, + "auto_install": False, + "installable": True, + "application": True, +} diff --git a/smile_partner_mail_history/i18n/fr.po b/smile_partner_mail_history/i18n/fr.po new file mode 100644 index 00000000..e5bc45c7 --- /dev/null +++ b/smile_partner_mail_history/i18n/fr.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * smile_partner_mail_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-08-06 15:15+0000\n" +"PO-Revision-Date: 2020-08-06 15:15+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: smile_partner_mail_history +#: model_terms:ir.ui.view,arch_db:smile_partner_mail_history.view_message_form_partner_mail_history +msgid "Body" +msgstr "Corps" + +#. module: smile_partner_mail_history +#: model:ir.model,name:smile_partner_mail_history.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: smile_partner_mail_history +#: model_terms:ir.ui.view,arch_db:smile_partner_mail_history.view_partner_form +msgid "History" +msgstr "Historique" + +#. module: smile_partner_mail_history +#: model_terms:ir.ui.view,arch_db:smile_partner_mail_history.view_message_form_partner_mail_history +msgid "Message" +msgstr "" + +#. module: smile_partner_mail_history +#: model_terms:ir.ui.view,arch_db:smile_partner_mail_history.view_message_tree_partner_mail_history +msgid "Messages" +msgstr "" + +#. module: smile_partner_mail_history +#: model:ir.model.fields,field_description:smile_partner_mail_history.field_res_partner__messages_count +#: model:ir.model.fields,field_description:smile_partner_mail_history.field_res_users__messages_count +msgid "Messages Count" +msgstr "Nombre de messages" + +#. module: smile_partner_mail_history +#: model_terms:ir.ui.view,arch_db:smile_partner_mail_history.view_message_form_partner_mail_history +msgid "Recipients" +msgstr "Destinataires" + +#. module: smile_partner_mail_history +#: code:addons/smile_partner_mail_history/models/res_partner.py:0 +#, python-format +msgid "This partner %s does not have any messages history!" +msgstr "Ce partenaire %s n'a pas d'historique de messages !" diff --git a/smile_partner_mail_history/models/__init__.py b/smile_partner_mail_history/models/__init__.py new file mode 100644 index 00000000..4ff37c22 --- /dev/null +++ b/smile_partner_mail_history/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (C) 2020 Smile () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import res_partner diff --git a/smile_partner_mail_history/models/res_partner.py b/smile_partner_mail_history/models/res_partner.py new file mode 100644 index 00000000..a3fde956 --- /dev/null +++ b/smile_partner_mail_history/models/res_partner.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# (C) 2020 Smile () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import fields, models, _ + +MAIL_MESSAGE_TYPES = ('email', 'comment', 'notification', 'user_notification') + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + messages_count = fields.Integer(compute='_compute_messages_count') + + def _compute_messages_count(self): + Message = self.env['mail.message'] + for partner in self: + partner.messages_count = Message.search_count([ + ('message_type', 'in', MAIL_MESSAGE_TYPES), + ('partner_ids', 'in', partner.id), + ]) + + def action_received_email_history(self): + """ + Show all received mail.message for a specific partner + """ + self.ensure_one() + action = self.env.ref('mail.action_view_mail_message') + result = action.read()[0] + result['views'] = [ + (self.env.ref( + 'smile_partner_mail_history.' + 'view_message_tree_partner_mail_history').id, + 'tree'), + (self.env.ref( + 'smile_partner_mail_history.' + 'view_message_form_partner_mail_history').id, + 'form'), + ] + result['domain'] = [ + ('message_type', 'in', MAIL_MESSAGE_TYPES), + ('partner_ids', 'in', self.ids) + ] + return result diff --git a/smile_partner_mail_history/static/description/icon.png b/smile_partner_mail_history/static/description/icon.png new file mode 100644 index 00000000..17984e2d Binary files /dev/null and b/smile_partner_mail_history/static/description/icon.png differ diff --git a/smile_partner_mail_history/static/description/index.html b/smile_partner_mail_history/static/description/index.html new file mode 100644 index 00000000..024a2e94 --- /dev/null +++ b/smile_partner_mail_history/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +Smile Partner Mail History + + + +
+

Smile Partner Mail History

+ +

License: AGPL-3 Smile-SA/odoo_addons

+

This module allows you to consult all partner's received messages (Emails, Chatter Notifications ...) through his form view.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to a partner Form view and click on smart button History.
  2. +
+
+Import +
+
    +
  1. You will be redirected to partner's received messages.
  2. +
+
+Import +
+
+
+

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 +here.

+
+
+

GDPR / EU Privacy

+

This addons does not collect any data and does not set any browser cookies.

+
+
+

Credits

+
+

Authors

+
    +
  • Smile SA
  • +
+
+
+

Contributors

+
    +
  • Isabelle RICHARD
  • +
  • Seif Iddine HAMMAMI
  • +
+
+
+

Maintainers

+

This module is maintained by the Smile SA.

+

Since 1991 Smile has been a pioneer of technology and also the European expert in open source solutions.

+Smile SA +

This module is part of the odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/smile_partner_mail_history/static/description/messages.png b/smile_partner_mail_history/static/description/messages.png new file mode 100644 index 00000000..e796f1a7 Binary files /dev/null and b/smile_partner_mail_history/static/description/messages.png differ diff --git a/smile_partner_mail_history/static/description/partner_form.png b/smile_partner_mail_history/static/description/partner_form.png new file mode 100644 index 00000000..270b6841 Binary files /dev/null and b/smile_partner_mail_history/static/description/partner_form.png differ diff --git a/smile_partner_mail_history/static/src/scss/partner_mail_history.scss b/smile_partner_mail_history/static/src/scss/partner_mail_history.scss new file mode 100644 index 00000000..3d4fca0c --- /dev/null +++ b/smile_partner_mail_history/static/src/scss/partner_mail_history.scss @@ -0,0 +1,3 @@ +.mail_message_tree .o_attachment.o_attachment_many2many { + width:100%; +} diff --git a/smile_partner_mail_history/tests/__init__.py b/smile_partner_mail_history/tests/__init__.py new file mode 100644 index 00000000..a70f2d7a --- /dev/null +++ b/smile_partner_mail_history/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# (C) 2020 Smile () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_mail_history diff --git a/smile_partner_mail_history/tests/test_mail_history.py b/smile_partner_mail_history/tests/test_mail_history.py new file mode 100644 index 00000000..60bb5a5c --- /dev/null +++ b/smile_partner_mail_history/tests/test_mail_history.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# (C) 2020 Smile () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase + + +class TestMailHistory(TransactionCase): + + def test_message_sent_to_partner_should_appear_in_history(self): + partner = self.env['res.partner'].create({ + 'name': 'Aude JAVEL', + 'email': 'aude.javel@example.com', + }) + message = partner.message_post(body="Wow, this is so clean!", + partner_ids=partner.ids) + result = partner.action_received_email_history() + expected_domain = [('id', 'in', message.ids)] + self.assertEquals(expected_domain, result.get('domain', [])) + + def test_message_sent_on_partner_should_not_appear_in_history(self): + partner = self.env['res.partner'].create({ + 'name': 'Alex TERRIEUR', + 'email': 'alex.terrieur@example.com', + }) + partner.message_post(body="Wow, this is so clean!", + partner_ids=[]) + with self.assertRaisesRegexp( + UserError, + "This partner Alex TERRIEUR does not " + "have any messages history!"): + partner.action_received_email_history() diff --git a/smile_partner_mail_history/views/mail_message_views.xml b/smile_partner_mail_history/views/mail_message_views.xml new file mode 100644 index 00000000..9ff65551 --- /dev/null +++ b/smile_partner_mail_history/views/mail_message_views.xml @@ -0,0 +1,75 @@ + + + + + + + mail.message.form.partner.mail.history + mail.message + 100 + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + mail.message.tree.partner.mail.history + mail.message + 100 + + + + + + + + + + + + + + +
+
diff --git a/smile_partner_mail_history/views/res_partner_views.xml b/smile_partner_mail_history/views/res_partner_views.xml new file mode 100644 index 00000000..f1e47590 --- /dev/null +++ b/smile_partner_mail_history/views/res_partner_views.xml @@ -0,0 +1,18 @@ + + + + + res.partner.view.form.inherit.partner.mail.history + res.partner + + + +
+ +
+
+
+
+