diff --git a/mail_print/__manifest__.py b/mail_print/__manifest__.py index be59378f29..b5cd2dcdca 100644 --- a/mail_print/__manifest__.py +++ b/mail_print/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Mail Print Message", - "version": "15.0.1.1.0", + "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", @@ -14,10 +14,8 @@ ], "assets": { "web.assets_backend": [ - "mail_print/static/src/components/**/*.esm.js", - ], - "web.assets_qweb": [ - "mail_print/static/src/components/*/*.xml", + "mail_print/static/src/**/*.esm.js", + "mail_print/static/src/**/*.xml", ], "web.assets_tests": [ "mail_print/static/tests/tours/**/*", diff --git a/mail_print/static/src/components/message_action_list/message_action_list.xml b/mail_print/static/src/components/message_action_list/message_action_list.xml deleted file mode 100644 index 6da3599445..0000000000 --- a/mail_print/static/src/components/message_action_list/message_action_list.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - 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 index 04b77560d6..6b018f9b15 100644 --- a/mail_print/static/src/components/print_message/print_message.esm.js +++ b/mail_print/static/src/components/print_message/print_message.esm.js @@ -2,19 +2,15 @@ /* Copyright 2024 Tecnativa - Carlos Lopez License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). */ -import {registerMessagingComponent} from "@mail/utils/messaging_component"; const {Component} = owl; export class PrintMessage extends Component { onClickPrintMessage() { - this.env.bus.trigger("do-action", { - action: "mail_print.mail_message_report", - options: { - additional_context: { - active_id: this.props.message_id, - active_ids: [this.props.message_id], - active_model: "mail.message", - }, + 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", }, }); } @@ -24,5 +20,3 @@ PrintMessage.template = "mail_print.PrintMessage"; PrintMessage.props = { message_id: Number, }; - -registerMessagingComponent(PrintMessage); diff --git a/mail_print/static/src/components/print_message/print_message.xml b/mail_print/static/src/components/print_message/print_message.xml index d116d787f1..5ab44ab817 100644 --- a/mail_print/static/src/components/print_message/print_message.xml +++ b/mail_print/static/src/components/print_message/print_message.xml @@ -1,13 +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 0000000000..d8e23e1b8f --- /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 index 9f3463ddc1..3475e991f7 100644 --- a/mail_print/static/tests/tours/mail_print.esm.js +++ b/mail_print/static/tests/tours/mail_print.esm.js @@ -2,7 +2,7 @@ /* Copyright 2024 Tecnativa - Carlos Lopez License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). */ -import tour from "web_tour.tour"; +import {registry} from "@web/core/registry"; const contact_steps = [ { trigger: ".o_navbar_apps_menu button", @@ -27,75 +27,40 @@ const contact_steps = [ }, { content: "Open contact", - trigger: ".o_list_table td[name='display_name']:contains('Test')", + trigger: ".o_list_table td[name='complete_name']:contains('Test')", }, ]; -tour.register( - "mail_print.mail_print_tour", - { - test: true, - url: "/web", - }, - [ +registry.category("web_tour.tours").add("mail_print.mail_print_tour", { + test: true, + url: "/web", + steps: () => [ ...contact_steps, - { - content: "Open Chat", - trigger: ".o_ChatterTopbar_buttonSendMessage", - run: "click", - }, - { - content: "Write a message", - trigger: ".o_ComposerTextInput_textarea", - run: "text Hello World", - }, - { - content: "Post a message", - trigger: ".o_Composer_buttonSend", - }, { content: "Hover a message", - trigger: "div.o_Message.o-discussion", + trigger: "div.o-mail-Message[aria-label='Message']", run: "click", }, { content: "Print a message", - trigger: ".o_MessageActionList_actionPrint", + trigger: ".mail_print_message", run: "click", }, - ] -); + ], +}); -tour.register( - "mail_print.mail_note_not_print_tour", - { - test: true, - url: "/web", - }, - [ +registry.category("web_tour.tours").add("mail_print.mail_note_not_print_tour", { + test: true, + url: "/web", + steps: () => [ ...contact_steps, - { - content: "Open Chat", - trigger: ".o_ChatterTopbar_buttonLogNote", - run: "click", - }, - { - content: "Write a note", - trigger: ".o_ComposerTextInput_textarea", - run: "text This is a note", - }, - { - content: "Post a note", - trigger: ".o_Composer_buttonSend", - }, { content: "Hover a note", - trigger: "div.o_Message.o-not-discussion", + trigger: "div.o-mail-Message[aria-label='Note']", run: "click", }, { content: "Verify that the Print button does not exist.", - trigger: - "div.o_Message.o-not-discussion:not(.o_MessageActionList_actionPrint)", + trigger: "div.o-mail-Message[aria-label='Note']:not(.mail_print_message)", }, - ] -); + ], +}); diff --git a/mail_print/tests/test_mail_print.py b/mail_print/tests/test_mail_print.py index b8cbeff83e..19e727b9ec 100644 --- a/mail_print/tests/test_mail_print.py +++ b/mail_print/tests/test_mail_print.py @@ -10,12 +10,20 @@ class TestMailPrint(HttpCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.env["res.partner"].with_context(tracking_disable=True).create( - {"name": "Test", "email": "test@example.com"} + 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")