From ef793cb5b22cc13b39734f82c83eaae60a62f33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Mon, 9 Mar 2020 13:50:44 +0000 Subject: [PATCH] [FIX] mail: Load record form view with user id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #45425 closes odoo/odoo#51717 X-original-commit: a210d68af04490c0daa535e3151ed5edbd431898 Signed-off-by: Alexandre Kühn (aku) --- .../static/src/js/services/mail_manager.js | 2 +- addons/mail/static/tests/discuss_tests.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/services/mail_manager.js b/addons/mail/static/src/js/services/mail_manager.js index c56cca019e0..04cc696d401 100644 --- a/addons/mail/static/src/js/services/mail_manager.js +++ b/addons/mail/static/src/js/services/mail_manager.js @@ -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); diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js index d04caf6c881..670b0865374 100644 --- a/addons/mail/static/tests/discuss_tests.js +++ b/addons/mail/static/tests/discuss_tests.js @@ -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: 'Link', + 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(); +}); + }); });