mirror of https://github.com/OCA/social.git
[IMP] mail_print: Migration to 17
parent
609747f0d0
commit
6015dfdc20
|
@ -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/**/*",
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-inherit="mail.MessageActionList" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//span[@t-if='messageActionList.hasReplyIcon']" position="before">
|
||||
<!-- Show the "Print Message" button only on messages, not on notes. -->
|
||||
<PrintMessage
|
||||
t-if="!messageActionList.message.is_note"
|
||||
message_id="messageActionList.message.id"
|
||||
/>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,
|
||||
});
|
|
@ -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)",
|
||||
},
|
||||
]
|
||||
);
|
||||
],
|
||||
});
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue