Skip to content
Snippets Groups Projects
Commit d8e80d7e authored by Abdelouahab (abla)'s avatar Abdelouahab (abla)
Browse files

[FIX] mail: uncheck recipient without partner

To reproduce
============
- on website add or edit **contact us** form to create a task on a project
- fill the form from Incognito
- on project -> the created task : try to send message on chatter
- you will find the email used when filling the form with possibilty
to check it as receiver
- check the box, a dialog will open to create a Partner for this email
- close the dialog without modifying anything

Problem
=======
the checkbox will remain checked, but when you send a message no email will be sent

Solution
========
as stated in this comment https://github.com/odoo/odoo/blob/de1f701e7bd7ebb6f7ebea5c097d980039c4f904/addons/mail/static/src/components/composer_suggested_recipient/composer_suggested_recipient.js#L128-L130


we will only send the message to partnenrs, so if no partner is
created we must uncheck the checkbox.

opw-3168779

closes odoo/odoo#113062

X-original-commit: 646888b8
Signed-off-by: default avatarSébastien Theys (seb) <seb@odoo.com>
parent 9d1074af
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@ import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
nextTick,
start,
} from '@mail/utils/test_utils';
......@@ -150,6 +151,46 @@ QUnit.test("suggested recipient without partner are unchecked by default", async
);
});
QUnit.test("suggested recipient without partner are unchecked when closing the dialog without creating partner", async function (assert) {
assert.expect(1);
this.data['res.fake'].records.push({
id: 10,
email_cc: "john@test.be",
});
const params = {
archs: {},
};
params.archs["res.partner,false,form"] = `
<form>
<field name="name"/>
</form>
`;
await this.start(params);
const chatter = this.messaging.models['mail.chatter'].create({
id: 11,
threadId: 10,
threadModel: 'res.fake',
});
await this.createChatterComponent({ chatter });
await afterNextRender(() =>
document.querySelector(`.o_ChatterTopbar_buttonSendMessage`).click()
);
// click on checkbox to open dialog
document.querySelector('.o_ComposerSuggestedRecipient:not([data-partner-id]) input[type=checkbox]').click();
await nextTick();
// close dialog without changing anything
document.querySelector('.modal-dialog .close').click();
assert.notOk(
document.querySelector('.o_ComposerSuggestedRecipient:not([data-partner-id]) input[type=checkbox]').checked,
"suggested recipient without partner must be unchecked",
);
});
QUnit.test("suggested recipient with partner are checked by default", async function (assert) {
assert.expect(1);
......
......@@ -19,6 +19,9 @@ class FormViewDialogComponentAdapter extends ComponentAdapter {
return this.willStart();
}
updateWidget() {
return Promise.resolve();
}
}
export class ComposerSuggestedRecipient extends Component {
......@@ -114,6 +117,7 @@ export class ComposerSuggestedRecipient extends Component {
this._isDialogOpen = true;
widget.on('closed', this, () => {
this._isDialogOpen = false;
this._checkboxRef.el.checked = !!this.suggestedRecipientInfo.partner;
});
widget.context = Object.assign({}, widget.context, session.user_context);
widget.open();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment