Skip to content

Commit

Permalink
[FIX] pivot: divergent collaborative duplicated pivot name
Browse files Browse the repository at this point in the history
Currently, if two users are connected to the same spreadsheet, both have
different languages and one of them duplicates a pivot: the spreadsheet
states have diverged because `_t(...)` gives two different results on both
sides.

Note that the command should ideally be upgraded with a script, but it's
not possible to get the original pivot name on the upgrade platform.

closes #5010

Task: 4199949
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
  • Loading branch information
LucasLefevre committed Oct 11, 2024
1 parent 31e1698 commit e98ad44
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/core/pivot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class PivotCorePlugin extends CorePlugin<CoreState> implements CoreState
case "DUPLICATE_PIVOT": {
const { pivotId, newPivotId } = cmd;
const pivot = deepCopy(this.getPivotCore(pivotId).definition);
pivot.name = _t("%s (copy)", pivot.name);
pivot.name = cmd.duplicatedPivotName ?? pivot.name + " (copy)";
this.addPivot(newPivotId, pivot);
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/ui_feature/insert_pivot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class InsertPivotPlugin extends UIPlugin {
this.dispatch("DUPLICATE_PIVOT", {
pivotId,
newPivotId,
duplicatedPivotName: _t("%s (copy)", this.getters.getPivotCoreDefinition(pivotId).name),
});
const activeSheetId = this.getters.getActiveSheetId();
const position = this.getters.getSheetIds().indexOf(activeSheetId) + 1;
Expand Down
2 changes: 2 additions & 0 deletions src/types/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ export interface DuplicatePivotCommand {
type: "DUPLICATE_PIVOT";
pivotId: UID;
newPivotId: string;
// an early version of the command did not include the duplicatedPivotName
duplicatedPivotName?: string;
}

// ------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions tests/test_helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ export const TEST_COMMANDS: CommandMapping = {
type: "DUPLICATE_PIVOT",
pivotId: "1",
newPivotId: "2",
duplicatedPivotName: "newName",
},
RENAME_PIVOT: {
type: "RENAME_PIVOT",
Expand Down

0 comments on commit e98ad44

Please sign in to comment.