[FIX] spreadsheet: download excel with filtered values

Open a spreadsheet, add a data filter, filter some values,
File > Download
=> the filtered values are not exported.

Previously, we gave the exported data to the action_download_spreadsheet
action, and we created a new model based on the data. This was a problem
for data that was only exported for the xlsx in UI plugins, because this
wasn't in the exported data.

Fixed by giving the xlsx data to the action_download_spreadsheet action instead
of the data.

Odoo task 3231170

closes odoo/odoo#124617

X-original-commit: 8a7e2ecf60993c6862c8980b70e847c0e5aa2a50
Related: odoo/enterprise#42355
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Minne Adrien (adrm) <adrm@odoo.com>
This commit is contained in:
Adrien Minne (adrm)
2023-06-12 15:26:50 +02:00
parent 9d4710a823
commit 2ef25b8372
@@ -9,15 +9,17 @@ import { createSpreadsheetModel, waitForDataLoaded } from "@spreadsheet/helpers/
* @param {object} action
*/
async function downloadSpreadsheet(env, action) {
const { name, data, stateUpdateMessages } = action.params;
const model = await createSpreadsheetModel({ env, data, revisions: stateUpdateMessages });
await waitForDataLoaded(model);
const { files } = model.exportXLSX();
let { name, data, stateUpdateMessages, xlsxData } = action.params;
if (!xlsxData) {
const model = await createSpreadsheetModel({ env, data, revisions: stateUpdateMessages });
await waitForDataLoaded(model);
xlsxData = model.exportXLSX();
}
await download({
url: "/spreadsheet/xlsx",
data: {
zip_name: `${name}.xlsx`,
files: JSON.stringify(files),
files: JSON.stringify(xlsxData.files),
},
});
}