@odoo/o-spreadsheet 18.3.31 → 18.3.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 18.3.31
6
- * @date 2025-12-26T10:18:10.765Z
7
- * @hash 1e143e1
5
+ * @version 18.3.32
6
+ * @date 2026-01-14T10:00:27.532Z
7
+ * @hash 8d1d321
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -18414,9 +18414,10 @@ stores.inject(MyMetaStore, storeInstance);
18414
18414
  throw new EvaluationError(_t("Function PIVOT takes an even number of arguments."));
18415
18415
  }
18416
18416
  }
18417
- function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
18417
+ function addPivotDependencies(evalContext, pivotId, forMeasures) {
18418
18418
  //TODO This function can be very costly when used with PIVOT.VALUE and PIVOT.HEADER
18419
18419
  const dependencies = [];
18420
+ const coreDefinition = evalContext.getters.getPivotCoreDefinition(pivotId);
18420
18421
  if (coreDefinition.type === "SPREADSHEET" && coreDefinition.dataSet) {
18421
18422
  const { sheetId, zone } = coreDefinition.dataSet;
18422
18423
  const xc = zoneToXc(zone);
@@ -18433,8 +18434,7 @@ stores.inject(MyMetaStore, storeInstance);
18433
18434
  }
18434
18435
  for (const measure of forMeasures) {
18435
18436
  if (measure.computedBy) {
18436
- const formula = evalContext.getters.getMeasureCompiledFormula(measure);
18437
- dependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
18437
+ dependencies.push(...evalContext.getters.getMeasureFullDependencies(pivotId, measure));
18438
18438
  }
18439
18439
  }
18440
18440
  const originPosition = evalContext.__originCellPosition;
@@ -18869,7 +18869,7 @@ stores.inject(MyMetaStore, storeInstance);
18869
18869
  assertDomainLength(domainArgs);
18870
18870
  const pivot = this.getters.getPivot(pivotId);
18871
18871
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
18872
- addPivotDependencies(this, coreDefinition, coreDefinition.measures.filter((m) => m.id === _measure));
18872
+ addPivotDependencies(this, pivotId, coreDefinition.measures.filter((m) => m.id === _measure));
18873
18873
  pivot.init({ reload: pivot.needsReevaluation });
18874
18874
  const error = pivot.assertIsValid({ throwOnError: false });
18875
18875
  if (error) {
@@ -18902,8 +18902,7 @@ stores.inject(MyMetaStore, storeInstance);
18902
18902
  const _pivotId = getPivotId(_pivotFormulaId, this.getters);
18903
18903
  assertDomainLength(domainArgs);
18904
18904
  const pivot = this.getters.getPivot(_pivotId);
18905
- const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
18906
- addPivotDependencies(this, coreDefinition, []);
18905
+ addPivotDependencies(this, _pivotId, []);
18907
18906
  pivot.init({ reload: pivot.needsReevaluation });
18908
18907
  const error = pivot.assertIsValid({ throwOnError: false });
18909
18908
  if (error) {
@@ -18957,7 +18956,7 @@ stores.inject(MyMetaStore, storeInstance);
18957
18956
  const pivotId = getPivotId(_pivotFormulaId, this.getters);
18958
18957
  const pivot = this.getters.getPivot(pivotId);
18959
18958
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
18960
- addPivotDependencies(this, coreDefinition, coreDefinition.measures);
18959
+ addPivotDependencies(this, pivotId, coreDefinition.measures);
18961
18960
  pivot.init({ reload: pivot.needsReevaluation });
18962
18961
  const error = pivot.assertIsValid({ throwOnError: false });
18963
18962
  if (error) {
@@ -23229,7 +23228,7 @@ stores.inject(MyMetaStore, storeInstance);
23229
23228
  }
23230
23229
  captureSelection(zone, col, row) {
23231
23230
  this.model.selection.capture(this, {
23232
- cell: { col: col ?? zone.left, row: row ?? zone.right },
23231
+ cell: { col: col ?? zone.left, row: row ?? zone.top },
23233
23232
  zone,
23234
23233
  }, {
23235
23234
  handleEvent: this.handleEvent.bind(this),
@@ -47617,6 +47616,12 @@ stores.inject(MyMetaStore, storeInstance);
47617
47616
  case "ACTIVATE_SHEET":
47618
47617
  this.isSearchDirty = true;
47619
47618
  this.shouldFinalizeUpdateSelection = true;
47619
+ if (this.searchOptions.specificRange) {
47620
+ this.searchOptions.specificRange = {
47621
+ ...this.searchOptions.specificRange,
47622
+ sheetId: this.getters.getActiveSheetId(),
47623
+ };
47624
+ }
47620
47625
  break;
47621
47626
  case "REPLACE_SEARCH":
47622
47627
  for (const match of cmd.matches) {
@@ -48038,9 +48043,20 @@ stores.inject(MyMetaStore, storeInstance);
48038
48043
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
48039
48044
  this.store.updateSearchOptions({ specificRange });
48040
48045
  }
48046
+ get specificRange() {
48047
+ const range = this.store.searchOptions.specificRange;
48048
+ return range ? this.env.model.getters.getRangeString(range, "forceSheetReference") : "";
48049
+ }
48041
48050
  get pendingSearch() {
48042
48051
  return this.updateSearchContent.isDebouncePending();
48043
48052
  }
48053
+ get selectionInputKey() {
48054
+ // Selections input are made to work with objects linked to a sheet id. They store the active sheet id at their creation,
48055
+ // and have specific behaviour linked to it (eg. go back to the initial sheet after confirmation).
48056
+ // We don't want all those behaviors here, so we force the recreation of the component when the active sheet changes.
48057
+ // The only drawback is that the input loses focus when changing sheet.
48058
+ return this.env.model.getters.getActiveSheetId();
48059
+ }
48044
48060
  }
48045
48061
 
48046
48062
  css /* scss */ `
@@ -62742,6 +62758,7 @@ stores.inject(MyMetaStore, storeInstance);
62742
62758
  "getMeasureCompiledFormula",
62743
62759
  "getPivotName",
62744
62760
  "isExistingPivot",
62761
+ "getMeasureFullDependencies",
62745
62762
  ];
62746
62763
  nextFormulaId = 1;
62747
62764
  pivots = {};
@@ -62824,7 +62841,7 @@ stores.inject(MyMetaStore, storeInstance);
62824
62841
  }
62825
62842
  case "UPDATE_PIVOT": {
62826
62843
  this.history.update("pivots", cmd.pivotId, "definition", this.repairSortedColumn(deepCopy(cmd.pivot)));
62827
- this.compileCalculatedMeasures(cmd.pivot.measures);
62844
+ this.compileCalculatedMeasures(cmd.pivotId, cmd.pivot.measures);
62828
62845
  break;
62829
62846
  }
62830
62847
  }
@@ -62842,9 +62859,14 @@ stores.inject(MyMetaStore, storeInstance);
62842
62859
  this.history.update("pivots", pivotId, "definition", newDefinition);
62843
62860
  }
62844
62861
  }
62845
- for (const sheetId in this.compiledMeasureFormulas) {
62846
- for (const formulaString in this.compiledMeasureFormulas[sheetId]) {
62847
- const compiledFormula = this.compiledMeasureFormulas[sheetId][formulaString];
62862
+ for (const pivotId in this.compiledMeasureFormulas) {
62863
+ for (const measureId in this.compiledMeasureFormulas[pivotId]) {
62864
+ const measure = this.pivots[pivotId]?.definition.measures.find((m) => m.id === measureId);
62865
+ if (!measure || !measure.computedBy) {
62866
+ continue;
62867
+ }
62868
+ const sheetId = measure.computedBy.sheetId;
62869
+ const compiledFormula = this.compiledMeasureFormulas[pivotId][measureId].formula;
62848
62870
  const newDependencies = [];
62849
62871
  for (const range of compiledFormula.dependencies) {
62850
62872
  const change = applyChange(range);
@@ -62856,8 +62878,9 @@ stores.inject(MyMetaStore, storeInstance);
62856
62878
  }
62857
62879
  }
62858
62880
  const newFormulaString = this.getters.getFormulaString(sheetId, compiledFormula.tokens, newDependencies);
62859
- if (newFormulaString !== formulaString) {
62860
- this.replaceMeasureFormula(sheetId, formulaString, newFormulaString);
62881
+ const oldFormulaString = measure.computedBy.formula;
62882
+ if (newFormulaString !== oldFormulaString) {
62883
+ this.replaceMeasureFormula(pivotId, measure, newFormulaString);
62861
62884
  }
62862
62885
  }
62863
62886
  }
@@ -62895,12 +62918,17 @@ stores.inject(MyMetaStore, storeInstance);
62895
62918
  isExistingPivot(pivotId) {
62896
62919
  return pivotId in this.pivots;
62897
62920
  }
62898
- getMeasureCompiledFormula(measure) {
62921
+ getMeasureCompiledFormula(pivotId, measure) {
62899
62922
  if (!measure.computedBy) {
62900
62923
  throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
62901
62924
  }
62902
- const sheetId = measure.computedBy.sheetId;
62903
- return this.compiledMeasureFormulas[sheetId][measure.computedBy.formula];
62925
+ return this.compiledMeasureFormulas[pivotId][measure.id].formula;
62926
+ }
62927
+ getMeasureFullDependencies(pivotId, measure) {
62928
+ if (!measure.computedBy) {
62929
+ throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
62930
+ }
62931
+ return this.compiledMeasureFormulas[pivotId][measure.id].dependencies;
62904
62932
  }
62905
62933
  // -------------------------------------------------------------------------
62906
62934
  // Private
@@ -62910,18 +62938,42 @@ stores.inject(MyMetaStore, storeInstance);
62910
62938
  definition: this.repairSortedColumn(deepCopy(pivot)),
62911
62939
  formulaId,
62912
62940
  });
62913
- this.compileCalculatedMeasures(pivot.measures);
62941
+ this.compileCalculatedMeasures(pivotId, pivot.measures);
62914
62942
  this.history.update("formulaIds", formulaId, pivotId);
62915
62943
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
62916
62944
  }
62917
- compileCalculatedMeasures(measures) {
62945
+ compileCalculatedMeasures(pivotId, measures) {
62918
62946
  for (const measure of measures) {
62919
62947
  if (measure.computedBy) {
62920
- const sheetId = measure.computedBy.sheetId;
62921
62948
  const compiledFormula = this.compileMeasureFormula(measure.computedBy.sheetId, measure.computedBy.formula);
62922
- this.history.update("compiledMeasureFormulas", sheetId, measure.computedBy.formula, compiledFormula);
62949
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "formula", compiledFormula);
62923
62950
  }
62924
62951
  }
62952
+ for (const measure of measures) {
62953
+ if (measure.computedBy) {
62954
+ const dependencies = this.computeMeasureFullDependencies(pivotId, measure);
62955
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", dependencies);
62956
+ }
62957
+ }
62958
+ }
62959
+ computeMeasureFullDependencies(pivotId, measure, exploredMeasures = new Set()) {
62960
+ const rangeDependencies = [];
62961
+ const definition = this.getPivotCoreDefinition(pivotId);
62962
+ const formula = this.getMeasureCompiledFormula(pivotId, measure);
62963
+ exploredMeasures.add(measure.id);
62964
+ for (const token of formula.tokens) {
62965
+ if (token.type !== "SYMBOL") {
62966
+ continue;
62967
+ }
62968
+ const otherMeasure = definition.measures.find((measureCandidate) => getCanonicalSymbolName(measureCandidate.id) === token.value &&
62969
+ measure.id !== measureCandidate.id);
62970
+ if (!otherMeasure || exploredMeasures.has(otherMeasure.id) || !otherMeasure.computedBy) {
62971
+ continue;
62972
+ }
62973
+ rangeDependencies.push(...this.computeMeasureFullDependencies(pivotId, otherMeasure, exploredMeasures));
62974
+ }
62975
+ rangeDependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
62976
+ return rangeDependencies;
62925
62977
  }
62926
62978
  insertPivot(position, formulaId, table) {
62927
62979
  this.resizeSheet(position.sheetId, position, table);
@@ -62981,21 +63033,17 @@ stores.inject(MyMetaStore, storeInstance);
62981
63033
  dependencies: rangeDependencies,
62982
63034
  };
62983
63035
  }
62984
- replaceMeasureFormula(sheetId, formulaString, newFormulaString) {
62985
- this.history.update("compiledMeasureFormulas", sheetId, formulaString, undefined);
62986
- this.history.update("compiledMeasureFormulas", sheetId, newFormulaString, this.compileMeasureFormula(sheetId, newFormulaString));
62987
- for (const pivotId in this.pivots) {
62988
- const pivot = this.pivots[pivotId];
62989
- if (!pivot) {
62990
- continue;
62991
- }
62992
- for (const measure of pivot.definition.measures) {
62993
- if (measure.computedBy?.formula === formulaString) {
62994
- const measureIndex = pivot.definition.measures.indexOf(measure);
62995
- this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", { formula: newFormulaString, sheetId });
62996
- }
62997
- }
63036
+ replaceMeasureFormula(pivotId, measure, newFormulaString) {
63037
+ const pivot = this.pivots[pivotId];
63038
+ if (!pivot) {
63039
+ return;
62998
63040
  }
63041
+ const measureIndex = pivot.definition.measures.indexOf(measure);
63042
+ this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", {
63043
+ formula: newFormulaString,
63044
+ sheetId: measure.computedBy.sheetId,
63045
+ });
63046
+ this.compileCalculatedMeasures(pivotId, pivot.definition.measures);
62999
63047
  }
63000
63048
  checkSortedColumnInMeasures(definition) {
63001
63049
  definition = this.repairSortedColumn(definition);
@@ -66285,14 +66333,16 @@ stores.inject(MyMetaStore, storeInstance);
66285
66333
  function withPivotPresentationLayer (PivotClass) {
66286
66334
  class PivotPresentationLayer extends PivotClass {
66287
66335
  getters;
66336
+ pivotId;
66288
66337
  cache = {};
66289
66338
  rankAsc = {};
66290
66339
  rankDesc = {};
66291
66340
  runningTotal = {};
66292
66341
  runningTotalInPercent = {};
66293
- constructor(custom, params) {
66342
+ constructor(pivotId, custom, params) {
66294
66343
  super(custom, params);
66295
66344
  this.getters = params.getters;
66345
+ this.pivotId = pivotId;
66296
66346
  }
66297
66347
  markAsDirtyForEvaluation() {
66298
66348
  this.cache = {};
@@ -66342,7 +66392,7 @@ stores.inject(MyMetaStore, storeInstance);
66342
66392
  return handleError(error, measure.aggregator.toUpperCase());
66343
66393
  }
66344
66394
  }
66345
- const formula = this.getters.getMeasureCompiledFormula(measure);
66395
+ const formula = this.getters.getMeasureCompiledFormula(this.pivotId, measure);
66346
66396
  const getSymbolValue = (symbolName) => {
66347
66397
  const { columns, rows } = this.definition;
66348
66398
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
@@ -67070,7 +67120,7 @@ stores.inject(MyMetaStore, storeInstance);
67070
67120
  const definition = deepCopy(this.getters.getPivotCoreDefinition(pivotId));
67071
67121
  if (!(pivotId in this.pivots)) {
67072
67122
  const Pivot = withPivotPresentationLayer(pivotRegistry.get(definition.type).ui);
67073
- this.pivots[pivotId] = new Pivot(this.custom, { definition, getters: this.getters });
67123
+ this.pivots[pivotId] = new Pivot(pivotId, this.custom, { definition, getters: this.getters });
67074
67124
  }
67075
67125
  else if (recreate) {
67076
67126
  this.pivots[pivotId].onDefinitionChange(definition);
@@ -81113,9 +81163,9 @@ stores.inject(MyMetaStore, storeInstance);
81113
81163
  exports.tokenize = tokenize;
81114
81164
 
81115
81165
 
81116
- __info__.version = "18.3.31";
81117
- __info__.date = "2025-12-26T10:18:10.765Z";
81118
- __info__.hash = "1e143e1";
81166
+ __info__.version = "18.3.32";
81167
+ __info__.date = "2026-01-14T10:00:27.532Z";
81168
+ __info__.hash = "8d1d321";
81119
81169
 
81120
81170
 
81121
81171
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);