[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:
@@ -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
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user