Skip to content

Commit

Permalink
[IMP] mail_print: Migration to 17
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-lopez-tecnativa committed Jan 7, 2025
1 parent 609747f commit 6015dfd
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 89 deletions.
8 changes: 3 additions & 5 deletions mail_print/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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/**/*",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
});
}
Expand All @@ -24,5 +20,3 @@ PrintMessage.template = "mail_print.PrintMessage";
PrintMessage.props = {
message_id: Number,
};

registerMessagingComponent(PrintMessage);
12 changes: 6 additions & 6 deletions mail_print/static/src/components/print_message/print_message.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<templates xml:space="preserve">
<t t-name="mail_print.PrintMessage" owl="1">
<span
class="o_MessageActionList_action o_MessageActionList_actionPrint p-2 fa fa-lg fa-print"
<t t-name="mail_print.PrintMessage">
<button
class="btn px-1 py-0 rounded-0 mail_print_message"
title="Print Message"
role="button"
tabindex="0"
aria-label="Print Message"
t-on-click="onClickPrintMessage"
/>
>
<i class="fa fa-lg fa-print" />
</button>
</t>
</templates>
11 changes: 11 additions & 0 deletions mail_print/static/src/core/common/message_actions.esm.js
Original file line number Diff line number Diff line change
@@ -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,
});
71 changes: 18 additions & 53 deletions mail_print/static/tests/tours/mail_print.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)",
},
]
);
],
});
12 changes: 10 additions & 2 deletions mail_print/tests/test_mail_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 6015dfd

Please sign in to comment.