[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) <luvi@odoo.com>
This commit is contained in:
Lucas Perais
2023-07-12 03:48:50 +02:00
parent 26ea33bc64
commit 450f79c896
2 changed files with 10 additions and 2 deletions
@@ -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();
@@ -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",