[MIG] web_send_message_popup: Migration to 16.0

pull/2657/head
Du-ma 2023-11-03 16:50:30 +02:00
parent 96c0d61f4e
commit 0be2b138ac
4 changed files with 65 additions and 60 deletions

View File

@ -7,7 +7,7 @@ Web Send Message as Popup
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:50f258f27e9b4cb2814665022c686779f90653dbf0854d3f04b498cdf6819d60
!! source digest: sha256:0083ff4f27d544631c17fd7354b1243d92d296ca3a3a9f61b183e739ec6e8346
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@ -17,13 +17,13 @@ Web Send Message as Popup
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/15.0/web_send_message_popup
:target: https://github.com/OCA/web/tree/16.0/web_send_message_popup
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_send_message_popup
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_send_message_popup
: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/web&target_branch=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -48,7 +48,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/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 <https://github.com/OCA/web/issues/new?body=module:%20web_send_message_popup%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_send_message_popup%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -83,6 +83,6 @@ 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/web <https://github.com/OCA/web/tree/15.0/web_send_message_popup>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_send_message_popup>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://gnu.org/licenses/agpl).
{
"name": "Web Send Message as Popup",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainer": "Camptocamp",
"license": "AGPL-3",

View File

@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:50f258f27e9b4cb2814665022c686779f90653dbf0854d3f04b498cdf6819d60
!! source digest: sha256:0083ff4f27d544631c17fd7354b1243d92d296ca3a3a9f61b183e739ec6e8346
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/15.0/web_send_message_popup"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_send_message_popup"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_send_message_popup"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_send_message_popup"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>In the email/notes threads below the form views, the link Send a
message unfold a text field. From there, a button allows to open the
text field in a full featured email popup with the subject, templates,
@ -394,7 +394,7 @@ if the popup is always wanted.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_send_message_popup%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_send_message_popup%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -423,7 +423,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_send_message_popup">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_send_message_popup">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -2,56 +2,61 @@
import {clear} from "@mail/model/model_field_command";
import {escapeAndCompactTextContent} from "@mail/js/utils";
import {registerInstancePatchModel} from "@mail/model/model_core";
import {registerPatch} from "@mail/model/model_core";
registerInstancePatchModel("mail.chatter", "web_send_message_popup.ChatterPatch", {
onClickSendMessage() {
if (this.composerView) {
// Change `isLog` to false since this should only be possible when you press
// "Log Note" first, otherwise this won't hurt.
this.composerView.composer.update({isLog: false});
// Open the full composer with `composerView` because it carries through the
// composer options.
this.composerView.openFullComposer();
// Clear the `composerView` since we don't need it no more.
this.update({composerView: clear()});
return;
}
this.openFullComposer();
},
openFullComposer() {
// Rough copy of composer view function `openFullComposer`.
// Get composer from thread.
// We access data from the composer since history still is saved there.
// e.g. open and close "Log note".
const composer = this.thread.composer;
const context = {
default_attachment_ids: composer.attachments.map((att) => att.id),
default_body: escapeAndCompactTextContent(composer.textInputContent),
default_is_log: false,
default_model: this.threadModel,
default_partner_ids: composer.recipients.map((partner) => partner.id),
default_res_id: this.threadId,
mail_post_autofollow: true,
};
const action = {
type: "ir.actions.act_window",
res_model: "mail.compose.message",
view_mode: "form",
views: [[false, "form"]],
target: "new",
context,
};
const options = {
on_close: () => {
if (composer.exists()) {
composer._reset();
if (composer.activeThread) {
composer.activeThread.loadNewMessages();
registerPatch({
name: "Chatter",
recordMethods: {
// Fn overwrite
onClickSendMessage() {
if (this.composerView) {
// Change `isLog` to false since this should only be possible when you
// press "Log Note" first, otherwise this won't hurt.
this.composerView.composer.update({isLog: false});
// Open the full composer with `composerView` because it carries through
// the composer options.
this.composerView.openFullComposer();
// Clear the `composerView` since we don't need it no more.
this.update({composerView: clear()});
return;
}
this.openFullComposer();
},
async openFullComposer() {
// Rough copy of composer view function `openFullComposer`.
// Get composer from thread.
// We access data from the composer since history still is saved there.
// e.g. open and close "Log note".
const composer = this.thread.composer;
const context = {
default_attachment_ids: composer.attachments.map((att) => att.id),
default_body: escapeAndCompactTextContent(composer.textInputContent),
default_is_log: false,
default_model: this.threadModel,
default_partner_ids: composer.recipients.map((partner) => partner.id),
default_res_id: this.threadId,
mail_post_autofollow: this.thread.hasWriteAccess,
};
const action = {
type: "ir.actions.act_window",
name: this.env._t("Compose Email"),
res_model: "mail.compose.message",
view_mode: "form",
views: [[false, "form"]],
target: "new",
context,
};
const options = {
on_close: () => {
if (composer.exists()) {
composer._reset();
if (composer.activeThread) {
composer.activeThread.fetchData(["messages"]);
}
}
}
},
};
this.env.bus.trigger("do-action", {action, options});
},
};
await this.env.services.action.doAction(action, options);
},
},
});