[IMP] mail: change relation of partner_id field

This commit helps reducing the noise of the model definition PR. Indeed,
the partner_id field on the mail.follower model was mocked as an integer
field. The /mail/thread/data route returns an integer. But the search
read method returns an array for many2one fields [id, display_name]. Thus,
using the real server field will result in an incorrect behavior.

task-2767820

closes odoo/odoo#86096

Related: odoo/enterprise#25125
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
tsm-odoo
2022-03-09 12:15:38 +00:00
parent dae20acffb
commit 74f55ac035
4 changed files with 10 additions and 6 deletions
@@ -403,10 +403,11 @@ QUnit.test('composer state conserved when clicking on another topbar button', as
QUnit.test('rendering with multiple partner followers', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({
id: 100,
message_follower_ids: [1, 2],
});
this.data['res.partner'].records.push(
{ id: 11 },
{ id: 12 },
{ id: 100, message_follower_ids: [1, 2] },
);
this.data['mail.followers'].records.push(
{
// simulate real return from RPC
@@ -148,7 +148,7 @@ QUnit.test('click on "add followers" button', async function (assert) {
partner.message_follower_ids.push(1);
payload.options.on_close();
});
this.data['res.partner'].records.push({ id: 100 });
this.data['res.partner'].records.push({ id: 100 }, { id: 42 });
this.data['mail.followers'].records.push({
partner_id: 42,
email: "bla@bla.bla",
@@ -117,7 +117,7 @@ export class MockModels {
is_active: { type: 'boolean' },
is_editable: { type: 'boolean' },
name: { type: 'char' },
partner_id: { type: 'integer' },
partner_id: { relation: 'res.partner', type: 'many2one' },
res_id: { type: 'many2one_reference' },
res_model: { type: 'char' },
subtype_ids: { type: 'many2many', relation: 'mail.message.subtype' }
@@ -541,6 +541,9 @@ MockServer.include({
['res_id', '=', thread.id],
['res_model', '=', thread_model],
]], {});
// search read returns many2one relations as an array [id, display_name].
// But the original route does not. Thus, we need to change it now.
followers.forEach(follower => follower.partner_id = follower.partner_id[0]);
res['followers'] = followers;
}
if (request_list.includes('suggestedRecipients')) {