From 2c1e070ad35b79fff874391d4c2e14a0a98c67b2 Mon Sep 17 00:00:00 2001 From: "Andrzej(pian)" Date: Mon, 5 Feb 2024 09:35:34 +0100 Subject: [PATCH] [FIX] mail: Fix thread object transfer to chatter in CRM email preview This commit addresses a problem in CRM where it was not possible to send emails directly from the preview window. The issue arose when returning to the chatter interface from the preview window, as the thread object was not properly passed back (to the chatter). This fix ensures the thread object is reintegrated into the chatter interface, resolving the email sending issue. Issue was traced back to the commit 5d99de10ec09244e10e4130573ad2e0c38e86009 [FIX] mail: do not reload chatter when not needed https://github.com/odoo/odoo/commit/5d99de10ec09244e10e4130573ad2e0c38e8600 [reproduce] - install crm - create activityTypes AT with an email template specified( crm/configuration/activityTypes) - open a Lead, ( crm/sales/MyPiepline) - schedule activity with activity type AT - click "preview" on the activity - click "send" or just close the preview -> BUG traceback opw-3680600 closes odoo/odoo#152698 Signed-off-by: Andrzej Pietrusiak (pian) --- addons/mail/static/src/core/web/activity_mail_template.js | 6 +++++- addons/mail/static/tests/activity/activity_tests.js | 7 +++++++ .../mail/static/tests/helpers/model_definitions_setup.js | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/core/web/activity_mail_template.js b/addons/mail/static/src/core/web/activity_mail_template.js index 243630c7678..c7c28be069a 100644 --- a/addons/mail/static/src/core/web/activity_mail_template.js +++ b/addons/mail/static/src/core/web/activity_mail_template.js @@ -46,8 +46,12 @@ export class ActivityMailTemplate extends Component { force_email: true, }, }; + const thread = this.store.Thread.get({ + model: this.props.activity.res_model, + id: this.props.activity.res_id, + }); this.env.services.action.doAction(action, { - onClose: () => this.props.onUpdate(), + onClose: () => this.props.onUpdate(thread), }); } diff --git a/addons/mail/static/tests/activity/activity_tests.js b/addons/mail/static/tests/activity/activity_tests.js index 68968dc3972..9fdd2a9ce80 100644 --- a/addons/mail/static/tests/activity/activity_tests.js +++ b/addons/mail/static/tests/activity/activity_tests.js @@ -22,6 +22,10 @@ const views = { `, + "mail.compose.message,false,form": ` +
+ + `, }; QUnit.module("activity"); @@ -301,6 +305,7 @@ QUnit.test("activity with mail template: preview mail", async (assert) => { assert.strictEqual(action.context.default_template_id, mailTemplateId); assert.strictEqual(action.type, "ir.actions.act_window"); assert.strictEqual(action.res_model, "mail.compose.message"); + return super.doAction(...arguments); }, }); await contains(".o-mail-Activity"); @@ -308,6 +313,8 @@ QUnit.test("activity with mail template: preview mail", async (assert) => { await click(".o-mail-ActivityMailTemplate-preview"); assert.verifySteps(["do_action"]); + await click(".btn-close"); + await contains(".o-mail-Activity"); // Just to make sure that closing the modal doesn't cause traceback }); QUnit.test("activity with mail template: send mail", async (assert) => { diff --git a/addons/mail/static/tests/helpers/model_definitions_setup.js b/addons/mail/static/tests/helpers/model_definitions_setup.js index 5ef351a625e..5d236065437 100644 --- a/addons/mail/static/tests/helpers/model_definitions_setup.js +++ b/addons/mail/static/tests/helpers/model_definitions_setup.js @@ -24,6 +24,7 @@ addModelNamesToFetch([ "discuss.channel.rtc.session", "discuss.gif.favorite", "discuss.voice.metadata", + "mail.compose.message", "mail.followers", "mail.guest", "mail.link.preview",