@odoo/o-spreadsheet 18.0.53 → 18.0.54

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.0.53
6
- * @date 2025-12-26T10:18:09.933Z
7
- * @hash 7ca8390
5
+ * @version 18.0.54
6
+ * @date 2026-01-14T10:00:02.287Z
7
+ * @hash c0048a0
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -18564,9 +18564,10 @@ stores.inject(MyMetaStore, storeInstance);
18564
18564
  throw new EvaluationError(_t("Function PIVOT takes an even number of arguments."));
18565
18565
  }
18566
18566
  }
18567
- function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
18567
+ function addPivotDependencies(evalContext, pivotId, forMeasures) {
18568
18568
  //TODO This function can be very costly when used with PIVOT.VALUE and PIVOT.HEADER
18569
18569
  const dependencies = [];
18570
+ const coreDefinition = evalContext.getters.getPivotCoreDefinition(pivotId);
18570
18571
  if (coreDefinition.type === "SPREADSHEET" && coreDefinition.dataSet) {
18571
18572
  const { sheetId, zone } = coreDefinition.dataSet;
18572
18573
  const xc = zoneToXc(zone);
@@ -18583,8 +18584,7 @@ stores.inject(MyMetaStore, storeInstance);
18583
18584
  }
18584
18585
  for (const measure of forMeasures) {
18585
18586
  if (measure.computedBy) {
18586
- const formula = evalContext.getters.getMeasureCompiledFormula(measure);
18587
- dependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
18587
+ dependencies.push(...evalContext.getters.getMeasureFullDependencies(pivotId, measure));
18588
18588
  }
18589
18589
  }
18590
18590
  const originPosition = evalContext.__originCellPosition;
@@ -19025,7 +19025,7 @@ stores.inject(MyMetaStore, storeInstance);
19025
19025
  assertDomainLength(domainArgs);
19026
19026
  const pivot = this.getters.getPivot(pivotId);
19027
19027
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
19028
- addPivotDependencies(this, coreDefinition, coreDefinition.measures.filter((m) => m.id === _measure));
19028
+ addPivotDependencies(this, pivotId, coreDefinition.measures.filter((m) => m.id === _measure));
19029
19029
  pivot.init({ reload: pivot.needsReevaluation });
19030
19030
  const error = pivot.assertIsValid({ throwOnError: false });
19031
19031
  if (error) {
@@ -19058,8 +19058,7 @@ stores.inject(MyMetaStore, storeInstance);
19058
19058
  const _pivotId = getPivotId(_pivotFormulaId, this.getters);
19059
19059
  assertDomainLength(domainArgs);
19060
19060
  const pivot = this.getters.getPivot(_pivotId);
19061
- const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
19062
- addPivotDependencies(this, coreDefinition, []);
19061
+ addPivotDependencies(this, _pivotId, []);
19063
19062
  pivot.init({ reload: pivot.needsReevaluation });
19064
19063
  const error = pivot.assertIsValid({ throwOnError: false });
19065
19064
  if (error) {
@@ -19113,7 +19112,7 @@ stores.inject(MyMetaStore, storeInstance);
19113
19112
  const pivotId = getPivotId(_pivotFormulaId, this.getters);
19114
19113
  const pivot = this.getters.getPivot(pivotId);
19115
19114
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
19116
- addPivotDependencies(this, coreDefinition, coreDefinition.measures);
19115
+ addPivotDependencies(this, pivotId, coreDefinition.measures);
19117
19116
  pivot.init({ reload: pivot.needsReevaluation });
19118
19117
  const error = pivot.assertIsValid({ throwOnError: false });
19119
19118
  if (error) {
@@ -42460,6 +42459,11 @@ stores.inject(MyMetaStore, storeInstance);
42460
42459
  case "UPDATE_CELL":
42461
42460
  case "ACTIVATE_SHEET":
42462
42461
  this.isSearchDirty = true;
42462
+ if (this.searchOptions.specificRange) {
42463
+ this.searchOptions.specificRange = this.searchOptions.specificRange.clone({
42464
+ sheetId: this.getters.getActiveSheetId(),
42465
+ });
42466
+ }
42463
42467
  break;
42464
42468
  case "REPLACE_SEARCH":
42465
42469
  for (const match of cmd.matches) {
@@ -42865,9 +42869,20 @@ stores.inject(MyMetaStore, storeInstance);
42865
42869
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
42866
42870
  this.store.updateSearchOptions({ specificRange });
42867
42871
  }
42872
+ get specificRange() {
42873
+ const range = this.store.searchOptions.specificRange;
42874
+ return range ? this.env.model.getters.getRangeString(range, "forceSheetReference") : "";
42875
+ }
42868
42876
  get pendingSearch() {
42869
42877
  return this.updateSearchContent.isDebouncePending();
42870
42878
  }
42879
+ get selectionInputKey() {
42880
+ // Selections input are made to work with objects linked to a sheet id. They store the active sheet id at their creation,
42881
+ // and have specific behaviour linked to it (eg. go back to the initial sheet after confirmation).
42882
+ // We don't want all those behaviors here, so we force the recreation of the component when the active sheet changes.
42883
+ // The only drawback is that the input loses focus when changing sheet.
42884
+ return this.env.model.getters.getActiveSheetId();
42885
+ }
42871
42886
  }
42872
42887
 
42873
42888
  css /* scss */ `
@@ -57204,6 +57219,7 @@ stores.inject(MyMetaStore, storeInstance);
57204
57219
  "getMeasureCompiledFormula",
57205
57220
  "getPivotName",
57206
57221
  "isExistingPivot",
57222
+ "getMeasureFullDependencies",
57207
57223
  ];
57208
57224
  nextFormulaId = 1;
57209
57225
  pivots = {};
@@ -57286,7 +57302,7 @@ stores.inject(MyMetaStore, storeInstance);
57286
57302
  }
57287
57303
  case "UPDATE_PIVOT": {
57288
57304
  this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
57289
- this.compileCalculatedMeasures(cmd.pivot.measures);
57305
+ this.compileCalculatedMeasures(cmd.pivotId, cmd.pivot.measures);
57290
57306
  break;
57291
57307
  }
57292
57308
  }
@@ -57304,9 +57320,14 @@ stores.inject(MyMetaStore, storeInstance);
57304
57320
  this.history.update("pivots", pivotId, "definition", newDefinition);
57305
57321
  }
57306
57322
  }
57307
- for (const sheetId in this.compiledMeasureFormulas) {
57308
- for (const formulaString in this.compiledMeasureFormulas[sheetId]) {
57309
- const compiledFormula = this.compiledMeasureFormulas[sheetId][formulaString];
57323
+ for (const pivotId in this.compiledMeasureFormulas) {
57324
+ for (const measureId in this.compiledMeasureFormulas[pivotId]) {
57325
+ const measure = this.pivots[pivotId]?.definition.measures.find((m) => m.id === measureId);
57326
+ if (!measure || !measure.computedBy) {
57327
+ continue;
57328
+ }
57329
+ const sheetId = measure.computedBy.sheetId;
57330
+ const compiledFormula = this.compiledMeasureFormulas[pivotId][measureId].formula;
57310
57331
  const newDependencies = [];
57311
57332
  for (const range of compiledFormula.dependencies) {
57312
57333
  const change = applyChange(range);
@@ -57318,8 +57339,9 @@ stores.inject(MyMetaStore, storeInstance);
57318
57339
  }
57319
57340
  }
57320
57341
  const newFormulaString = this.getters.getFormulaString(sheetId, compiledFormula.tokens, newDependencies);
57321
- if (newFormulaString !== formulaString) {
57322
- this.replaceMeasureFormula(sheetId, formulaString, newFormulaString);
57342
+ const oldFormulaString = measure.computedBy.formula;
57343
+ if (newFormulaString !== oldFormulaString) {
57344
+ this.replaceMeasureFormula(pivotId, measure, newFormulaString);
57323
57345
  }
57324
57346
  }
57325
57347
  }
@@ -57357,30 +57379,59 @@ stores.inject(MyMetaStore, storeInstance);
57357
57379
  isExistingPivot(pivotId) {
57358
57380
  return pivotId in this.pivots;
57359
57381
  }
57360
- getMeasureCompiledFormula(measure) {
57382
+ getMeasureCompiledFormula(pivotId, measure) {
57361
57383
  if (!measure.computedBy) {
57362
57384
  throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
57363
57385
  }
57364
- const sheetId = measure.computedBy.sheetId;
57365
- return this.compiledMeasureFormulas[sheetId][measure.computedBy.formula];
57386
+ return this.compiledMeasureFormulas[pivotId][measure.id].formula;
57387
+ }
57388
+ getMeasureFullDependencies(pivotId, measure) {
57389
+ if (!measure.computedBy) {
57390
+ throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
57391
+ }
57392
+ return this.compiledMeasureFormulas[pivotId][measure.id].dependencies;
57366
57393
  }
57367
57394
  // -------------------------------------------------------------------------
57368
57395
  // Private
57369
57396
  // -------------------------------------------------------------------------
57370
57397
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
57371
57398
  this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
57372
- this.compileCalculatedMeasures(pivot.measures);
57399
+ this.compileCalculatedMeasures(pivotId, pivot.measures);
57373
57400
  this.history.update("formulaIds", formulaId, pivotId);
57374
57401
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
57375
57402
  }
57376
- compileCalculatedMeasures(measures) {
57403
+ compileCalculatedMeasures(pivotId, measures) {
57377
57404
  for (const measure of measures) {
57378
57405
  if (measure.computedBy) {
57379
- const sheetId = measure.computedBy.sheetId;
57380
57406
  const compiledFormula = this.compileMeasureFormula(measure.computedBy.sheetId, measure.computedBy.formula);
57381
- this.history.update("compiledMeasureFormulas", sheetId, measure.computedBy.formula, compiledFormula);
57407
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "formula", compiledFormula);
57382
57408
  }
57383
57409
  }
57410
+ for (const measure of measures) {
57411
+ if (measure.computedBy) {
57412
+ const dependencies = this.computeMeasureFullDependencies(pivotId, measure);
57413
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", dependencies);
57414
+ }
57415
+ }
57416
+ }
57417
+ computeMeasureFullDependencies(pivotId, measure, exploredMeasures = new Set()) {
57418
+ const rangeDependencies = [];
57419
+ const definition = this.getPivotCoreDefinition(pivotId);
57420
+ const formula = this.getMeasureCompiledFormula(pivotId, measure);
57421
+ exploredMeasures.add(measure.id);
57422
+ for (const token of formula.tokens) {
57423
+ if (token.type !== "SYMBOL") {
57424
+ continue;
57425
+ }
57426
+ const otherMeasure = definition.measures.find((measureCandidate) => getCanonicalSymbolName(measureCandidate.id) === token.value &&
57427
+ measure.id !== measureCandidate.id);
57428
+ if (!otherMeasure || exploredMeasures.has(otherMeasure.id) || !otherMeasure.computedBy) {
57429
+ continue;
57430
+ }
57431
+ rangeDependencies.push(...this.computeMeasureFullDependencies(pivotId, otherMeasure, exploredMeasures));
57432
+ }
57433
+ rangeDependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
57434
+ return rangeDependencies;
57384
57435
  }
57385
57436
  insertPivot(position, formulaId, table) {
57386
57437
  this.resizeSheet(position.sheetId, position, table);
@@ -57438,21 +57489,17 @@ stores.inject(MyMetaStore, storeInstance);
57438
57489
  dependencies: rangeDependencies,
57439
57490
  };
57440
57491
  }
57441
- replaceMeasureFormula(sheetId, formulaString, newFormulaString) {
57442
- this.history.update("compiledMeasureFormulas", sheetId, formulaString, undefined);
57443
- this.history.update("compiledMeasureFormulas", sheetId, newFormulaString, this.compileMeasureFormula(sheetId, newFormulaString));
57444
- for (const pivotId in this.pivots) {
57445
- const pivot = this.pivots[pivotId];
57446
- if (!pivot) {
57447
- continue;
57448
- }
57449
- for (const measure of pivot.definition.measures) {
57450
- if (measure.computedBy?.formula === formulaString) {
57451
- const measureIndex = pivot.definition.measures.indexOf(measure);
57452
- this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", { formula: newFormulaString, sheetId });
57453
- }
57454
- }
57492
+ replaceMeasureFormula(pivotId, measure, newFormulaString) {
57493
+ const pivot = this.pivots[pivotId];
57494
+ if (!pivot) {
57495
+ return;
57455
57496
  }
57497
+ const measureIndex = pivot.definition.measures.indexOf(measure);
57498
+ this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", {
57499
+ formula: newFormulaString,
57500
+ sheetId: measure.computedBy.sheetId,
57501
+ });
57502
+ this.compileCalculatedMeasures(pivotId, pivot.definition.measures);
57456
57503
  }
57457
57504
  checkDuplicatedMeasureIds(definition) {
57458
57505
  const uniqueIds = new Set(definition.measures.map((m) => m.id));
@@ -60744,14 +60791,16 @@ stores.inject(MyMetaStore, storeInstance);
60744
60791
  function withPivotPresentationLayer (PivotClass) {
60745
60792
  class PivotPresentationLayer extends PivotClass {
60746
60793
  getters;
60794
+ pivotId;
60747
60795
  cache = {};
60748
60796
  rankAsc = {};
60749
60797
  rankDesc = {};
60750
60798
  runningTotal = {};
60751
60799
  runningTotalInPercent = {};
60752
- constructor(custom, params) {
60800
+ constructor(pivotId, custom, params) {
60753
60801
  super(custom, params);
60754
60802
  this.getters = params.getters;
60803
+ this.pivotId = pivotId;
60755
60804
  }
60756
60805
  markAsDirtyForEvaluation() {
60757
60806
  this.cache = {};
@@ -60801,7 +60850,7 @@ stores.inject(MyMetaStore, storeInstance);
60801
60850
  return handleError(error, measure.aggregator.toUpperCase());
60802
60851
  }
60803
60852
  }
60804
- const formula = this.getters.getMeasureCompiledFormula(measure);
60853
+ const formula = this.getters.getMeasureCompiledFormula(this.pivotId, measure);
60805
60854
  const getSymbolValue = (symbolName) => {
60806
60855
  const { columns, rows } = this.definition;
60807
60856
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
@@ -61519,7 +61568,7 @@ stores.inject(MyMetaStore, storeInstance);
61519
61568
  const definition = deepCopy(this.getters.getPivotCoreDefinition(pivotId));
61520
61569
  if (!(pivotId in this.pivots)) {
61521
61570
  const Pivot = withPivotPresentationLayer(pivotRegistry.get(definition.type).ui);
61522
- this.pivots[pivotId] = new Pivot(this.custom, { definition, getters: this.getters });
61571
+ this.pivots[pivotId] = new Pivot(pivotId, this.custom, { definition, getters: this.getters });
61523
61572
  }
61524
61573
  else if (recreate) {
61525
61574
  this.pivots[pivotId].onDefinitionChange(definition);
@@ -74793,9 +74842,9 @@ stores.inject(MyMetaStore, storeInstance);
74793
74842
  exports.tokenize = tokenize;
74794
74843
 
74795
74844
 
74796
- __info__.version = "18.0.53";
74797
- __info__.date = "2025-12-26T10:18:09.933Z";
74798
- __info__.hash = "7ca8390";
74845
+ __info__.version = "18.0.54";
74846
+ __info__.date = "2026-01-14T10:00:02.287Z";
74847
+ __info__.hash = "c0048a0";
74799
74848
 
74800
74849
 
74801
74850
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);