From 450f79c896ce0fe4c7918d637bc731a39d90dd4c Mon Sep 17 00:00:00 2001 From: Lucas Perais Date: Thu, 29 Jun 2023 11:40:31 +0000 Subject: [PATCH] [FIX] web: actionService reports: pass action's context to download Before this commit, the report action's context was not passed to the download route. This was problematic as some crucial keys may be forgotten when downloading the pdf. After this commit, we do pass the full context to the download route, ensuring consistency of the context across calls. closes odoo/odoo#126963 Related: odoo/enterprise#43441 Signed-off-by: Luca Vitali (luvi) --- addons/web/static/src/webclient/actions/action_service.js | 6 +++++- .../tests/webclient/actions/reports/report_action_tests.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 45a92c92ae0..cb489325115 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -1081,11 +1081,15 @@ function makeActionManager(env) { let success, message; env.services.ui.block(); try { + const downloadContext = { ...env.services.user.context }; + if (action.context) { + Object.assign(downloadContext, action.context); + } ({ success, message } = await downloadReport( env.services.rpc, action, type, - env.services.user.context + downloadContext )); } finally { env.services.ui.unblock(); diff --git a/addons/web/static/tests/webclient/actions/reports/report_action_tests.js b/addons/web/static/tests/webclient/actions/reports/report_action_tests.js index 596e1837ebf..9112a253c1c 100644 --- a/addons/web/static/tests/webclient/actions/reports/report_action_tests.js +++ b/addons/web/static/tests/webclient/actions/reports/report_action_tests.js @@ -318,10 +318,14 @@ QUnit.module("ActionManager", (hooks) => { }); QUnit.test("context is correctly passed to the client action report", async (assert) => { - assert.expect(8); + assert.expect(9); mockDownload((options) => { assert.step(options.url); + assert.deepEqual( + options.data.context, + `{"lang":"en","uid":7,"tz":"taht","rabbia":"E Tarantella","active_ids":[99]}` + ); assert.deepEqual(JSON.parse(options.data.data), [ "/report/pdf/ennio.morricone/99", "qweb-pdf",