Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] figure,chart: Enforce unicity of figure ids #2157

Closed
wants to merge 1 commit into from

Conversation

rrahir
Copy link
Collaborator

@rrahir rrahir commented Mar 3, 2023

Description:

The issue of duplicated chart ids was first addressed in PR #2102 by
trying to defined chart ids per sheet (just like figures)
Unfortunately, the fix was not appropriate for several reasons:

  1. Some commands in Odoo were not dispatching the sheetId along with the
    chartId, making the mapping sheetId, chartId hazardous
  2. There was absolutely 0 verification that the commands targeting a
    chartId were also providing a sheet Id that matched. So the said
    commands cannot be trusted either

This commit is exploring the other solution that is forcing the unicity
of a figure id. The data are adapted so that figures with a duplicated
id well have the latter updated to ensure unicity.

This commit also tries to solve the wrong sheetId parameter in
UPDATE_CHART by simply ignoring it in the commands. It's not necesarry
since we now have the unicity of figure ids.
15.0-fix-charts-rar (#2157)
description of this task, what is implemented and why it is implemented that way.

Odoo task ID : TASK_ID

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_lt("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Mar 3, 2023

src/plugins/core/chart.ts Outdated Show resolved Hide resolved
@@ -239,7 +242,7 @@ export class ChartPanel extends Component<Props, SpreadsheetEnv> {
private updateChart(definition: ChartUIDefinitionUpdate): DispatchResult {
return this.env.dispatch("UPDATE_CHART", {
id: this.props.figure.id,
sheetId: this.getters.getActiveSheetId(),
sheetId: this.state.chartSheetId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sheetId in this command is still unused, right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not here ,but it's actually used starting v16.0

this.state.chart = this.env.getters.getChartDefinitionUI(
this.env.getters.getActiveSheetId(),
this.state.chartSheetId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it in the state ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no good reason , no need for reactivity as it changes with the figure - you're right

@@ -343,6 +385,55 @@ function dropCommands(initialMessages, commandType: string) {
return messages;
}

function fixUpdateChart(data: Partial<WorkbookData>, initialMessages: StateUpdateMessage[]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why it's needed since cmd.sheetId is unused anyway
(and should be eventually removed)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, used in 16.0+ atm

@rrahir rrahir force-pushed the 15.0-fix-charts-rar branch 2 times, most recently from a1a1d02 to dc9c259 Compare March 3, 2023 13:07
The issue of duplicated chart ids was first addressed in PR #2102 by
trying to defined chart ids per sheet (just like figures)
Unfortunately, the fix was not appropriate for several reasons:
1. Some commands in Odoo were not dispatching the sheetId along with the
   chartId, making the mapping sheetId, chartId hazardous
2. There was absolutely 0 verification that the commands targeting a
   chartId were also providing a sheet Id that matched. So the said
   commands cannot be trusted either

This commit is exploring the other solution that is forcing the unicity
of a figure id. The data are adapted so that figures with a duplicated
id well have the latter updated to ensure unicity.

This commit also tries to solve the wrong `sheetId` parameter in
`UPDATE_CHART` by simply ignoring it in the commands. It's not necesarry
since we now have the unicity of figure ids.
Copy link
Collaborator

@pro-odoo pro-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robodoo r+

robodoo pushed a commit that referenced this pull request Mar 3, 2023
The issue of duplicated chart ids was first addressed in PR #2102 by
trying to defined chart ids per sheet (just like figures)
Unfortunately, the fix was not appropriate for several reasons:
1. Some commands in Odoo were not dispatching the sheetId along with the
   chartId, making the mapping sheetId, chartId hazardous
2. There was absolutely 0 verification that the commands targeting a
   chartId were also providing a sheet Id that matched. So the said
   commands cannot be trusted either

This commit is exploring the other solution that is forcing the unicity
of a figure id. The data are adapted so that figures with a duplicated
id well have the latter updated to ensure unicity.

This commit also tries to solve the wrong `sheetId` parameter in
`UPDATE_CHART` by simply ignoring it in the commands. It's not necesarry
since we now have the unicity of figure ids.

closes #2157

Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
@robodoo robodoo temporarily deployed to merge March 3, 2023 15:46 Inactive
@robodoo robodoo closed this Mar 3, 2023
@fw-bot fw-bot deleted the 15.0-fix-charts-rar branch March 17, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants