Skip to content

Conversation

@fw-bot
Copy link
Collaborator

@fw-bot fw-bot commented Nov 28, 2025

When calling the method chartToImage, the chartJs extensions might not be loaded as we load them conditionally when mounting a chart. Hence, calling ChartToImage when there are no visible charts in the viewport or if we just instantiate a model without loading a component Spreadsheet, the extensions will be missing.

Right now, the plugins/extensions are not fundamental to convert a chart to an image but this becomes problematic with the arrival of future charts (for instance Funnel).

This commit adds a check to ensure that the extensisons are loaded and unloads them after use as they can cause crashes when using the global ChartJs variable elsewhere (see #6076).

Task: 5214007

Description:

description of this task, what is implemented and why it is implemented that way.

Task: 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 (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

Forward-Port-Of: #7379

@robodoo
Copy link
Collaborator

robodoo commented Nov 28, 2025

Pull request status dashboard

@fw-bot
Copy link
Collaborator Author

fw-bot commented Nov 28, 2025

@rrahir @LucasLefevre cherrypicking of pull request #7379 failed.

stdout:

CONFLICT (modify/delete): src/helpers/figures/charts/chart_ui_common.ts deleted in b7280f758c9c7e1d1c06bcdf51ef6e7c87b7a792 and modified in 99076ea95edcd4e5e85a4eb86df6f1be1f42adb6.  Version 99076ea95edcd4e5e85a4eb86df6f1be1f42adb6 of src/helpers/figures/charts/chart_ui_common.ts left in tree.

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

⚠️ after resolving this conflict, you will need to merge it via @robodoo.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@rrahir rrahir force-pushed the master-saas-18.3-fix-missing-chart-deps-rar-480969-fw branch from 74b36d1 to e8f82b7 Compare November 28, 2025 21:06
@rrahir
Copy link
Collaborator

rrahir commented Nov 28, 2025

this one is troublesome, the code to convert to images clearly depends on chart js and therefore browser behaviour.

this tries to reflect the reality regarding the possible absence of
chartJs when running the library. The typing assumes that the library is
always loaded but when it's not, a random line of code will crash while
trying to access window.Chart.
Through this revision, we explicitely handle the absence of chart js and
throw an explicit error.
At the moment, when the chart js library is not loaded or if it is
missing some plugins (like geo chart or funnel), trying to convert a
chart to an image file or and image url will crash.

This revision adds some checks to let the conversion fail silently
without breaking the whole conversion flow. This will prove useful when
trying to convert charts during an xlsx export if the code is running
server side and without a proper access to chart.js.

Task: 0
When calling the method chartToImage, the chartJs extensions might not
be loaded as we load them conditionally when mounting a chart. Hence,
calling `ChartToImage` when there are no visible charts in the viewport
or if we just instantiate a model without loading a component
`Spreadsheet`, the extensions will be missing.

Right now, the plugins/extensions are not fundamental to convert a chart
to an image but this becomes problematic with the arrival of future
charts (for instance Funnel).

This commit adds a check to ensure that the extensisons are loaded and
unloads them after use as they can cause crashes when using the global
`ChartJs` variable elsewhere (see #6076).

Task: 5214007
X-original-commit: d146422
@rrahir rrahir force-pushed the master-saas-18.3-fix-missing-chart-deps-rar-480969-fw branch from e8f82b7 to b5bbf00 Compare December 1, 2025 21:40
@rrahir
Copy link
Collaborator

rrahir commented Dec 1, 2025

@VincentSchippefilt could you have a look ? since it is a forwardport at firt but I added the suggestion we talked about :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants