From 68ff6fe9cebd1430069cdf7fc1c06190779dc684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre=20=28lul=29?= Date: Wed, 18 Oct 2023 16:15:35 +0200 Subject: [PATCH] [IMP] spreadsheet: store pivot table structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need to recompute the table structure every time. The pivot model is never mutated, we can safely store the table. closes odoo/odoo#138594 Related: odoo/enterprise#48910 Signed-off-by: Rémi Rahir (rar) --- addons/spreadsheet/static/src/pivot/pivot_model.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/spreadsheet/static/src/pivot/pivot_model.js b/addons/spreadsheet/static/src/pivot/pivot_model.js index 960ee921aab..25b202c7b8b 100644 --- a/addons/spreadsheet/static/src/pivot/pivot_model.js +++ b/addons/spreadsheet/static/src/pivot/pivot_model.js @@ -376,10 +376,18 @@ export class SpreadsheetPivotModel extends PivotModel { return domains ? domains[0] : Domain.FALSE.toList(); } + getTableStructure() { + if (this._tableStructure === undefined) { + // lazy build the structure + this._tableStructure = this._buildTableStructure(); + } + return this._tableStructure; + } + /** * @returns {SpreadsheetPivotTable} */ - getTableStructure() { + _buildTableStructure() { const cols = this._getSpreadsheetCols(); const rows = this._getSpreadsheetRows(this.data.rowGroupTree); rows.push(rows.shift()); //Put the Total row at the end.