diff --git a/mail_print/README.rst b/mail_print/README.rst new file mode 100644 index 000000000..a139cace6 --- /dev/null +++ b/mail_print/README.rst @@ -0,0 +1,83 @@ +================== +Mail Print Message +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0cd861f29fc0a68aebccb18a4db08b607f68edca8c3672e499e013ed99f8fda6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/mail_print + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_print + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows users to print messages from the chatter of any +document. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, follow these steps: + +1. Navigate to the chatter of any document. +2. Hover the mouse over any message in the chatter (excluding internal + notes). +3. A print icon will appear next to the message. +4. Click the print icon to generate a printable version of the message. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_print/__init__.py b/mail_print/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/mail_print/__manifest__.py b/mail_print/__manifest__.py new file mode 100644 index 000000000..b5cd2dcdc --- /dev/null +++ b/mail_print/__manifest__.py @@ -0,0 +1,27 @@ +# Copyright 2024 Tecnativa - Carlos Lopez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Mail Print Message", + "version": "17.0.1.0.0", + "summary": "Print messages from the chatter of any document. ", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "depends": ["mail", "contacts"], + "data": [ + "data/report_paperformat_data.xml", + "reports/report_mail_message.xml", + "reports/reports.xml", + ], + "assets": { + "web.assets_backend": [ + "mail_print/static/src/**/*.esm.js", + "mail_print/static/src/**/*.xml", + ], + "web.assets_tests": [ + "mail_print/static/tests/tours/**/*", + ], + }, + "installable": True, + "auto_install": False, + "license": "AGPL-3", +} diff --git a/mail_print/data/report_paperformat_data.xml b/mail_print/data/report_paperformat_data.xml new file mode 100644 index 000000000..e18090448 --- /dev/null +++ b/mail_print/data/report_paperformat_data.xml @@ -0,0 +1,15 @@ + + + + + Mail Message + A4 + Portrait + 30 + 20 + 5 + 5 + 25 + + + diff --git a/mail_print/i18n/es.po b/mail_print/i18n/es.po new file mode 100644 index 000000000..393339768 --- /dev/null +++ b/mail_print/i18n/es.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_print +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-01 12:27+0000\n" +"PO-Revision-Date: 2024-10-01 07:28-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: \n" +"X-Generator: Poedit 3.0.1\n" + +#. module: mail_print +#: model:ir.actions.report,print_report_name:mail_print.mail_message_report +msgid "(object.display_name)" +msgstr "" + +#. module: mail_print +#: model_terms:ir.ui.view,arch_db:mail_print.report_mail_message_document +msgid "" +"
\n" +" Reply-To: " +msgstr "" +"
\n" +" Responder a: " + +#. module: mail_print +#: model_terms:ir.ui.view,arch_db:mail_print.report_mail_message_document +msgid "" +"
\n" +" To: " +msgstr "" +"
\n" +" Para: " + +#. module: mail_print +#: model_terms:ir.ui.view,arch_db:mail_print.report_mail_message_document +msgid "Date: " +msgstr "Fecha: " + +#. module: mail_print +#: model:ir.actions.report,name:mail_print.mail_message_report +msgid "Message" +msgstr "Mensaje" + +#. module: mail_print +#. openerp-web +#: code:addons/mail_print/static/src/components/print_message/print_message.xml:0 +#, python-format +msgid "Print Message" +msgstr "Imprimir Mensaje" diff --git a/mail_print/i18n/mail_print.pot b/mail_print/i18n/mail_print.pot new file mode 100644 index 000000000..1b453114c --- /dev/null +++ b/mail_print/i18n/mail_print.pot @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_print +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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_print +#: model:ir.actions.report,print_report_name:mail_print.mail_message_report +msgid "(object.display_name)" +msgstr "" + +#. module: mail_print +#: model_terms:ir.ui.view,arch_db:mail_print.report_mail_message_document +msgid "" +"
\n" +" Reply-To: " +msgstr "" + +#. module: mail_print +#: model_terms:ir.ui.view,arch_db:mail_print.report_mail_message_document +msgid "" +"
\n" +" To: " +msgstr "" + +#. module: mail_print +#: model_terms:ir.ui.view,arch_db:mail_print.report_mail_message_document +msgid "Date: " +msgstr "" + +#. module: mail_print +#: model:ir.actions.report,name:mail_print.mail_message_report +msgid "Message" +msgstr "" + +#. module: mail_print +#. openerp-web +#: code:addons/mail_print/static/src/components/print_message/print_message.xml:0 +#: code:addons/mail_print/static/src/components/print_message/print_message.xml:0 +#, python-format +msgid "Print Message" +msgstr "" diff --git a/mail_print/pyproject.toml b/mail_print/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/mail_print/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_print/readme/DESCRIPTION.md b/mail_print/readme/DESCRIPTION.md new file mode 100644 index 000000000..d1c1a9be8 --- /dev/null +++ b/mail_print/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows users to print messages from the chatter of any +document. diff --git a/mail_print/readme/USAGE.md b/mail_print/readme/USAGE.md new file mode 100644 index 000000000..9dcc56bc6 --- /dev/null +++ b/mail_print/readme/USAGE.md @@ -0,0 +1,7 @@ +To use this module, follow these steps: + +1. Navigate to the chatter of any document. +2. Hover the mouse over any message in the chatter (excluding internal + notes). +3. A print icon will appear next to the message. +4. Click the print icon to generate a printable version of the message. diff --git a/mail_print/reports/report_mail_message.xml b/mail_print/reports/report_mail_message.xml new file mode 100644 index 000000000..7df40f210 --- /dev/null +++ b/mail_print/reports/report_mail_message.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/mail_print/reports/reports.xml b/mail_print/reports/reports.xml new file mode 100644 index 000000000..ed1bf4d4a --- /dev/null +++ b/mail_print/reports/reports.xml @@ -0,0 +1,13 @@ + + + + Message + mail.message + qweb-pdf + mail_print.report_mail_message + mail_print.report_mail_message + (object.display_name) + + + + diff --git a/mail_print/static/description/icon.png b/mail_print/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mail_print/static/description/icon.png differ diff --git a/mail_print/static/description/index.html b/mail_print/static/description/index.html new file mode 100644 index 000000000..94d377b01 --- /dev/null +++ b/mail_print/static/description/index.html @@ -0,0 +1,429 @@ + + + + + +Mail Print Message + + + +
+

Mail Print Message

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

+

This module allows users to print messages from the chatter of any +document.

+

Table of contents

+ +
+

Usage

+

To use this module, follow these steps:

+
    +
  1. Navigate to the chatter of any document.
  2. +
  3. Hover the mouse over any message in the chatter (excluding internal +notes).
  4. +
  5. A print icon will appear next to the message.
  6. +
  7. Click the print icon to generate a printable version of the message.
  8. +
+
+
+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/mail_print/static/src/components/print_message/print_message.esm.js b/mail_print/static/src/components/print_message/print_message.esm.js new file mode 100644 index 000000000..6b018f9b1 --- /dev/null +++ b/mail_print/static/src/components/print_message/print_message.esm.js @@ -0,0 +1,22 @@ +/** @odoo-module **/ +/* Copyright 2024 Tecnativa - Carlos Lopez + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +*/ +const {Component} = owl; + +export class PrintMessage extends Component { + onClickPrintMessage() { + this.env.services.action.doAction("mail_print.mail_message_report", { + additionalContext: { + active_id: this.props.message_id, + active_ids: [this.props.message_id], + active_model: "mail.message", + }, + }); + } +} + +PrintMessage.template = "mail_print.PrintMessage"; +PrintMessage.props = { + message_id: Number, +}; diff --git a/mail_print/static/src/components/print_message/print_message.xml b/mail_print/static/src/components/print_message/print_message.xml new file mode 100644 index 000000000..5ab44ab81 --- /dev/null +++ b/mail_print/static/src/components/print_message/print_message.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/mail_print/static/src/core/common/message_actions.esm.js b/mail_print/static/src/core/common/message_actions.esm.js new file mode 100644 index 000000000..d8e23e1b8 --- /dev/null +++ b/mail_print/static/src/core/common/message_actions.esm.js @@ -0,0 +1,11 @@ +/* @odoo-module */ + +import {PrintMessage} from "../../components/print_message/print_message.esm"; +import {messageActionsRegistry} from "@mail/core/common/message_actions"; + +messageActionsRegistry.add("print", { + callComponent: PrintMessage, + props: (component) => ({message_id: component.props.message.id}), + condition: (component) => !component.props.message.is_note, + sequence: 10, +}); diff --git a/mail_print/static/tests/tours/mail_print.esm.js b/mail_print/static/tests/tours/mail_print.esm.js new file mode 100644 index 000000000..3475e991f --- /dev/null +++ b/mail_print/static/tests/tours/mail_print.esm.js @@ -0,0 +1,66 @@ +/** @odoo-module */ +/* Copyright 2024 Tecnativa - Carlos Lopez + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +*/ +import {registry} from "@web/core/registry"; +const contact_steps = [ + { + trigger: ".o_navbar_apps_menu button", + }, + { + trigger: '.o_app[data-menu-xmlid="contacts.menu_contacts"]', + }, + { + content: "Search Contact", + trigger: ".o_searchview_input", + run: "text Test", + }, + { + trigger: ".o_menu_item", + content: "Validate search", + run: "click", + }, + { + content: "Switch to list view", + trigger: ".o_list", + run: "click", + }, + { + content: "Open contact", + trigger: ".o_list_table td[name='complete_name']:contains('Test')", + }, +]; +registry.category("web_tour.tours").add("mail_print.mail_print_tour", { + test: true, + url: "/web", + steps: () => [ + ...contact_steps, + { + content: "Hover a message", + trigger: "div.o-mail-Message[aria-label='Message']", + run: "click", + }, + { + content: "Print a message", + trigger: ".mail_print_message", + run: "click", + }, + ], +}); + +registry.category("web_tour.tours").add("mail_print.mail_note_not_print_tour", { + test: true, + url: "/web", + steps: () => [ + ...contact_steps, + { + content: "Hover a note", + trigger: "div.o-mail-Message[aria-label='Note']", + run: "click", + }, + { + content: "Verify that the Print button does not exist.", + trigger: "div.o-mail-Message[aria-label='Note']:not(.mail_print_message)", + }, + ], +}); diff --git a/mail_print/tests/__init__.py b/mail_print/tests/__init__.py new file mode 100644 index 000000000..6cffb37e1 --- /dev/null +++ b/mail_print/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_print diff --git a/mail_print/tests/test_mail_print.py b/mail_print/tests/test_mail_print.py new file mode 100644 index 000000000..19e727b9e --- /dev/null +++ b/mail_print/tests/test_mail_print.py @@ -0,0 +1,29 @@ +# Copyright 2024 Tecnativa - Carlos Lopez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests import tagged +from odoo.tests.common import HttpCase + + +@tagged("post_install", "-at_install") +class TestMailPrint(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = ( + cls.env["res.partner"] + .with_context(tracking_disable=True) + .create({"name": "Test", "email": "test@example.com"}) + ) + + def test_01_mail_print_tour(self): + self.partner.message_post( + body="Hello World", message_type="comment", subtype_xmlid="mail.mt_comment" + ) + self.start_tour("/web", "mail_print.mail_print_tour", login="admin") + + def test_02_mail_note_not_print_tour(self): + self.partner.message_post( + body="This is a note", message_type="comment", subtype_xmlid="mail.mt_note" + ) + self.start_tour("/web", "mail_print.mail_note_not_print_tour", login="admin")