[FIX] spreadsheet: faster compute format

`getReportMeasures` is called repeatedly for every pivot function.
In HBA's demo spreadsheet it takes up to 30% of the loading time.

Part-of: odoo/odoo#138166
This commit is contained in:
Lucas Lefèvre (lul)
2023-10-10 11:07:59 +00:00
parent 568be9e7b8
commit 3ef421c1d2
3 changed files with 1 additions and 11 deletions
@@ -51,11 +51,6 @@ export default class PivotDataSource extends OdooViewsDataSource {
return model;
}
getReportMeasures() {
this._assertDataIsLoaded();
return this._model.getReportMeasures();
}
/**
* @param {string[]} domain
*/
@@ -68,7 +68,7 @@ const ODOO_PIVOT = {
computeFormat: function (pivotId, measureName, ...domain) {
pivotId = toString(pivotId.value);
const measure = toString(measureName.value);
const field = this.getters.getPivotDataSource(pivotId).getReportMeasures()[measure];
const field = this.getters.getPivotDataSource(pivotId).getField(measure);
if (!field) {
return undefined;
}
@@ -4,7 +4,6 @@ import { _t } from "@web/core/l10n/translation";
import { Domain } from "@web/core/domain";
import { sprintf } from "@web/core/utils/strings";
import { PivotModel } from "@web/views/pivot/pivot_model";
import { computeReportMeasures } from "@web/views/utils";
import * as spreadsheet from "@odoo/o-spreadsheet";
import { PERIODS } from "@spreadsheet/pivot/pivot_helpers";
@@ -201,10 +200,6 @@ export class SpreadsheetPivotModel extends PivotModel {
return field.string + (aggregateOperator ? ` (${PERIODS[aggregateOperator]})` : "");
}
getReportMeasures() {
return computeReportMeasures(this.metaData.fields, this.metaData.fieldAttrs, []);
}
//--------------------------------------------------------------------------
// Cell missing
//--------------------------------------------------------------------------