Skip to content
Permalink
Browse files

[FIX] mail: reset suggested partner when record saved

After you once click on 'Send Message' of composer, if you change
the details of the partner(e.g email address), you will have to reload
the page in order to actually get the modified details of follower in
the chatter

We fixed this so that there won't be a need to reload the page for
getting the modified data.

After this commit, when you click on 'Send Message' and then modify
details of partner and save it, it will reset the suggested recipients.
So now when you again click on 'Send Message', it will call
get_suggested_recipients method again to get modified data.

task-2089816
  • Loading branch information
pch-odoo authored and msh-odoo committed Oct 23, 2019
1 parent 68b0f9c commit 07c098aa3234aa98e38be8e4067e8993eb88e7e6
Showing with 73 additions and 0 deletions.
  1. +18 −0 addons/mail/static/src/js/form_controller.js
  2. +55 −0 addons/mail/static/tests/chatter_tests.js
@@ -13,6 +13,24 @@ FormController.include({
new_message: '_onNewMessage', new_message: '_onNewMessage',
}), }),


//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------

/**
*
* @override
*/
saveRecord() {
var chatter = this.renderer.chatter;
return this._super(...arguments).then(changedFields => {
if (chatter) {
chatter.trigger_up('reset_suggested_partners');
}
return changedFields;
});
},

//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Handlers // Handlers
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@@ -3325,6 +3325,61 @@ QUnit.test('chatter: display suggested partners only once', async function (asse
form.destroy(); form.destroy();
}); });


QUnit.test('chatter: display modified partner info in follower info of composer without refreshing', async function (assert) {
assert.expect(5);

let formSaved = false;

const form = await createView({
View: FormView,
model: 'partner',
data: this.data,
services: this.services,
arch: `
<form string="Partners">
<sheet>
<field name="foo"/>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread" options="{'display_log_button': True}"/>
</div>
</form>`,
res_id: 2,
viewOptions: {
mode: 'edit',
},
async mockRPC(route, args) {
if (route === '/mail/get_suggested_recipients') {
assert.step('get_suggested_recipients');
if (formSaved) {
return { 2: [[2, "HELLO2"]], };
}
return { 2: [[2, "HELLO"]], };
}
return this._super(route, args);
},
});

await testUtils.dom.click(form.$('.o_chatter_button_new_message'));
assert.strictEqual(
form.$('div.o_composer_suggested_partners label').text().replace(/\s+/g, ''),
"HELLO",
"should have the correct original email label");
await testUtils.fields.editInput(form.$('.o_field_char'), 'HELLO2');
await testUtils.dom.click(form.$('.o_form_button_save'));
formSaved = true;
await testUtils.dom.click(form.$('.o_chatter_button_new_message'));
assert.verifySteps(['get_suggested_recipients', 'get_suggested_recipients'],
'route should be called two times');
assert.strictEqual(
form.$('div.o_composer_suggested_partners label').text().replace(/\s+/g, ''),
"HELLO2",
"should have the correct modified email label");

form.destroy();
});

QUnit.module('FieldMany2ManyTagsEmail', { QUnit.module('FieldMany2ManyTagsEmail', {
beforeEach: function () { beforeEach: function () {
this.data = { this.data = {

0 comments on commit 07c098a

Please sign in to comment.
You can’t perform that action at this time.