[FIX] mail: Load record form view with user id

fixes #45425

closes odoo/odoo#51717

X-original-commit: a210d68af04490c0daa535e3151ed5edbd431898
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Lucas Lefèvre
2020-05-22 15:15:21 +00:00
parent 15eaba09a7
commit ef793cb5b2
2 changed files with 39 additions and 1 deletions
@@ -1032,7 +1032,7 @@ var MailManager = AbstractService.extend({
this._rpc({
model: resModel,
method: 'get_formview_id',
args: [[resID], session.user_context],
args: [[resID], session.user_context.uid],
})
.then(function (viewID) {
self._redirectToDocument(resModel, resID, viewID);
+38
View File
@@ -2034,5 +2034,43 @@ QUnit.test('no crash on receiving needaction channel message notif with messagin
discuss.destroy();
});
QUnit.test('load record form view', async function (assert) {
assert.expect(4);
this.data['mail.message'].records = [{
author_id: [5, 'Demo User'],
body: '<a id="test_redirect_link" href="#" data-oe-model="my.model" data-oe-id="10">Link</a>',
id: 1,
needaction: true,
needaction_partner_ids: [3],
res_id: 100,
model: 'some.document',
record_name: 'SomeDocument',
}];
const discuss = await createDiscuss({
context: {},
params: {},
data: this.data,
services: this.services,
session: {
partner_id: 3,
user_context: { uid: 99 },
},
async mockRPC(route, args) {
if (args.model === 'my.model' && args.method === 'get_formview_id') {
const [resIds, uid] = args.args;
assert.step('get_redirect_form');
assert.deepEqual(resIds, [10],
"should have have called with the correct ID");
assert.strictEqual(uid, 99,
"should have have called with the current user");
}
return this._super(...arguments);
},
});
await testUtils.dom.click(discuss.$('#test_redirect_link'));
assert.verifySteps(['get_redirect_form']);
discuss.destroy();
});
});
});