[FIX] mail: set full composer subject and recipients
task-2291887 task-2291893 task-2291898 closes odoo/odoo#54531 X-original-commit: 26170ad9ab09d75de2e0af98fb7daedc2ed57e50 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
committed by
Alexandre Kühn
parent
04a757d596
commit
c767df5e97
@@ -15,7 +15,6 @@ const {
|
||||
isEventHandled,
|
||||
markEventHandled,
|
||||
} = require('mail/static/src/utils/utils.js');
|
||||
const mailUtils = require('mail.utils');
|
||||
|
||||
const { Component } = owl;
|
||||
const { useRef } = owl.hooks;
|
||||
@@ -227,33 +226,8 @@ class Composer extends Component {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
async _onClickFullComposer() {
|
||||
const attachmentIds = this.composer.attachments.map(attachment => attachment.res_id);
|
||||
|
||||
const context = {
|
||||
// default_parent_id: this.id,
|
||||
default_body: mailUtils.escapeAndCompactTextContent(this.composer.textInputContent),
|
||||
default_attachment_ids: attachmentIds,
|
||||
// default_partner_ids: partnerIds,
|
||||
default_is_log: this.composer.isLog,
|
||||
mail_post_autofollow: true,
|
||||
};
|
||||
|
||||
// if (this.context.default_model && this.context.default_res_id) {
|
||||
// context.default_model = this.context.default_model;
|
||||
// context.default_res_id = this.context.default_res_id;
|
||||
// }
|
||||
|
||||
const action = {
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'mail.compose.message',
|
||||
view_mode: 'form',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
context: context,
|
||||
};
|
||||
await this.env.bus.trigger('do-action', { action });
|
||||
this.trigger('o-full-composer-opened');
|
||||
_onClickFullComposer() {
|
||||
this.composer.openFullComposer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ odoo.define('mail/static/src/models/composer/composer.js', function (require) {
|
||||
const emojis = require('mail.emojis');
|
||||
const { registerNewModel } = require('mail/static/src/model/model_core.js');
|
||||
const { attr, many2many, many2one, one2one } = require('mail/static/src/model/model_field.js');
|
||||
const mailUtils = require('mail.utils');
|
||||
|
||||
const {
|
||||
addLink,
|
||||
@@ -81,6 +82,43 @@ function factory(dependencies) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the full composer modal.
|
||||
*/
|
||||
async openFullComposer() {
|
||||
const attachmentIds = this.attachments.map(attachment => attachment.res_id);
|
||||
|
||||
const context = {
|
||||
default_attachment_ids: attachmentIds,
|
||||
default_body: mailUtils.escapeAndCompactTextContent(this.textInputContent),
|
||||
default_is_log: this.isLog,
|
||||
default_model: this.thread.model,
|
||||
/* FIXME would need to use suggested_partners here task-2280157 */
|
||||
// default_partner_ids: partnerIds,
|
||||
default_res_id: this.thread.id,
|
||||
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: context,
|
||||
};
|
||||
const options = {
|
||||
on_close: () => {
|
||||
if (!this.constructor.get(this)) {
|
||||
return;
|
||||
}
|
||||
this._reset();
|
||||
this.thread.loadNewMessages();
|
||||
},
|
||||
};
|
||||
await this.env.bus.trigger('do-action', { action, options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a message in provided composer's thread based on current composer fields values.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
odoo.define('mail/static/tests/tours/mail_full_composer_test_tour.js', function (require) {
|
||||
"use strict";
|
||||
|
||||
const tour = require('web_tour.tour');
|
||||
|
||||
/**
|
||||
* This tour depends on data created by python test in charge of launching it.
|
||||
* It is not intended to work when launched from interface. It is needed to test
|
||||
* an action (action manager) which is not possible to test with QUnit.
|
||||
* @see mail/tests/test_mail_full_composer.py
|
||||
*/
|
||||
tour.register('mail/static/tests/tours/mail_full_composer_test_tour.js', {
|
||||
test: true,
|
||||
}, [{
|
||||
content: "Click on Send Message",
|
||||
trigger: '.o_ChatterTopbar_buttonSendMessage',
|
||||
}, {
|
||||
content: "Write something in composer",
|
||||
trigger: '.o_ComposerTextInput_textarea',
|
||||
run: 'text blahblah',
|
||||
}, {
|
||||
content: "Open full composer",
|
||||
trigger: '.o_Composer_buttonFullComposer',
|
||||
}, {
|
||||
content: "Check subject is autofilled",
|
||||
trigger: 'input[name="subject"]',
|
||||
run: () => {
|
||||
const subjectValue = document.querySelector('input[name="subject"]').value;
|
||||
if (subjectValue !== "Re: Test User") {
|
||||
console.error(
|
||||
`Full composer should have "Re: Test User" in subject input (actual: ${subjectValue})`
|
||||
);
|
||||
}
|
||||
},
|
||||
}, {
|
||||
content: "Check composer content is kept",
|
||||
trigger: '.oe_form_field[name="body"]',
|
||||
run: () => {
|
||||
const bodyContent = document.querySelector('.oe_form_field[name="body"] textarea').textContent;
|
||||
if (!bodyContent.includes("blahblah")) {
|
||||
console.error(
|
||||
`Full composer should contain text from small composer ("blahblah") in body input (actual: ${bodyContent})`
|
||||
);
|
||||
}
|
||||
},
|
||||
}, {
|
||||
content: "Open templates",
|
||||
trigger: '.o_field_widget[name="template_id"] input',
|
||||
}, {
|
||||
content: "Check a template is listed",
|
||||
in_modal: false,
|
||||
trigger: '.ui-autocomplete .ui-menu-item a:contains("Test template")',
|
||||
run: () => {},
|
||||
}, {
|
||||
content: "Send message",
|
||||
trigger: '.o_mail_send',
|
||||
}, {
|
||||
content: "Check message is shown",
|
||||
trigger: '.o_Message:contains("blahblah")',
|
||||
}]);
|
||||
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import common
|
||||
from . import test_mail_full_composer
|
||||
from . import test_res_partner
|
||||
from . import test_update_notification
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests.common import tagged, HttpCase
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class TestMailFullComposer(HttpCase):
|
||||
|
||||
def test_full_composer_tour(self):
|
||||
self.env['mail.template'].create({
|
||||
'name': 'Test template',
|
||||
'partner_to': '${object.id}',
|
||||
'lang': '${object.lang}',
|
||||
'auto_delete': True,
|
||||
'model_id': self.ref('base.model_res_partner'),
|
||||
})
|
||||
testuser = self.env['res.users'].create({
|
||||
'email': 'testuser@testuser.com',
|
||||
'groups_id': [(6, 0, [self.ref('base.group_user'), self.ref('base.group_partner_manager')])],
|
||||
'name': 'Test User',
|
||||
'login': 'testuser',
|
||||
'password': 'testuser',
|
||||
})
|
||||
self.start_tour("/web#id=%d&model=res.partner" % testuser.partner_id, 'mail/static/tests/tours/mail_full_composer_test_tour.js', login='testuser')
|
||||
@@ -219,6 +219,9 @@
|
||||
</template>
|
||||
|
||||
<template id="assets_tests" name="Mail Assets Tests" inherit_id="web.assets_tests">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/mail/static/tests/tours/mail_full_composer_test_tour.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="tests_assets" name="mail_tests_assets" inherit_id="web.tests_assets">
|
||||
|
||||
Reference in New Issue
Block a user