[FIX] spreadsheet: download xlsx with active filters

This commit allows to download a spreadsheet with active filters
without any crash.

Commit https://github.com/odoo/odoo/commit/509bda2202df9f0f582fd020d96e8e1310b9abc7
was a first attempt to fix the issue.

But the commit was wrong because an empty sheet for excel is not the
same as an empty regular sheet. The `charts` property is missing and
the excel would crash when trying to read it.

Task 3102330

closes odoo/odoo#108603

X-original-commit: 0db14f258c31366ab53728735b4d31b4576c5269
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
Lucas Lefèvre
2022-12-23 17:03:40 +01:00
committed by Rémi Rahir
parent afd5408bf5
commit 03061e09ad
2 changed files with 3 additions and 3 deletions
@@ -39,7 +39,7 @@ const MONTHS = {
december: { value: 12, granularity: "month" },
};
const { UuidGenerator } = spreadsheet.helpers;
const { UuidGenerator, createEmptyExcelSheet } = spreadsheet.helpers;
const uuidGenerator = new UuidGenerator();
export default class GlobalFiltersUIPlugin extends spreadsheet.UIPlugin {
@@ -439,8 +439,7 @@ export default class GlobalFiltersUIPlugin extends spreadsheet.UIPlugin {
row++;
}
data.sheets.push({
id: uuidGenerator.uuidv4(),
name: "Active Filters",
...createEmptyExcelSheet(uuidGenerator.uuidv4(), _t("Active Filters")),
cells,
colNumber: 2,
rowNumber: this.getters.getGlobalFilters().length + 1,
@@ -1151,6 +1151,7 @@ QUnit.module("spreadsheet > Global filters model", {}, () => {
filterSheet.cells["B2"].content,
model.getters.getFilterDisplayValue(filter.label)
);
model.exportXLSX(); // should not crash
});
QUnit.test("Date filter automatic default value for years filter", async function (assert) {