From 2ef25b8372bbd6c3b929b4069e09d15280aa68d5 Mon Sep 17 00:00:00 2001 From: "Adrien Minne (adrm)" Date: Tue, 14 Mar 2023 11:17:12 +0000 Subject: [PATCH] [FIX] spreadsheet: download excel with filtered values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Signed-off-by: Minne Adrien (adrm) --- .../src/actions/spreadsheet_download_action.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/spreadsheet/static/src/actions/spreadsheet_download_action.js b/addons/spreadsheet/static/src/actions/spreadsheet_download_action.js index 5ebb8036d5d..b5ed3546140 100644 --- a/addons/spreadsheet/static/src/actions/spreadsheet_download_action.js +++ b/addons/spreadsheet/static/src/actions/spreadsheet_download_action.js @@ -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), }, }); }