Skip to content

Conversation

anhe-odoo
Copy link
Contributor

Task Description

When using empty matrices for math operation (multiplication or inversion), as in the FORECAST formula, we got a traceback and the error message was not clear for the user. This commits aims to fix it by checking that the matrices used in theses operations are not empty and returning an understandable error if it's not the case.

Related Task

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

@robodoo
Copy link
Collaborator

robodoo commented Aug 13, 2025

Pull request status dashboard

@anhe-odoo anhe-odoo force-pushed the 17.0-evaluation-prevent_operation_on_empty_matrixes-anhe branch from db98c21 to 7c1ef64 Compare August 21, 2025 11:06
Copy link
Collaborator

@rrahir rrahir left a comment

Choose a reason for hiding this comment

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

jus a bit of nitpick ^^ what do you think?


export function assertNonEmpty(...data: any[][]) {
if (data.length === 0 || data.some((arg) => arg.length === 0)) {
throw new NotAvailableError(_t("[[FUNCTION_NAME]] has no valid input."));
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably will need to be adapted in 18.4 following #6248

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was aware of that :)


export function assertNonEmpty(...data: any[][]) {
if (data.length === 0 || data.some((arg) => arg.length === 0)) {
throw new NotAvailableError(_t("[[FUNCTION_NAME]] has no valid input."));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
throw new NotAvailableError(_t("[[FUNCTION_NAME]] has no valid input."));
throw new NotAvailableError(_t("[[FUNCTION_NAME]] contains empty input data."));

only a part of the input is invalid in this case.

That being said, I like the idea of the assert above that provides the name of the faulty argument to help out.
maybe something like

    throw new NotAvailableError(_t("[[FUNCTION_NAME]] expects the provided values of %(argName)s to contain values.", {argName}));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't be possible as the filterAndFlatData used before will return both data_x and data_y filtered so that we ignore every value of an array if the value at the same position of the other array is undefined or null. So if we have data_X OR data_Y empty, both will be filtered to empty array

@anhe-odoo anhe-odoo force-pushed the 17.0-evaluation-prevent_operation_on_empty_matrixes-anhe branch from 7c1ef64 to 019e255 Compare September 2, 2025 13:39
Task Description

When using empty matrices for math operation (multiplication or
inversion), as in the FORECAST formula, we got a traceback and the
error message was not clear for the user. This commits aims to fix
it by checking that the matrices used in theses operations are not
empty and returning an understandable error if it's not the case.

Related Task

Task: 5001658
@anhe-odoo anhe-odoo force-pushed the 17.0-evaluation-prevent_operation_on_empty_matrixes-anhe branch from 019e255 to 3490d0e Compare September 2, 2025 13:56
@rrahir
Copy link
Collaborator

rrahir commented Sep 2, 2025

robodoo r+

robodoo pushed a commit that referenced this pull request Sep 2, 2025
Task Description

When using empty matrices for math operation (multiplication or
inversion), as in the FORECAST formula, we got a traceback and the
error message was not clear for the user. This commits aims to fix
it by checking that the matrices used in theses operations are not
empty and returning an understandable error if it's not the case.

Related Task

closes #6930

Task: 5001658
Signed-off-by: Rémi Rahir (rar) <[email protected]>
robodoo pushed a commit that referenced this pull request Sep 2, 2025
Task Description

When using empty matrices for math operation (multiplication or
inversion), as in the FORECAST formula, we got a traceback and the
error message was not clear for the user. This commits aims to fix
it by checking that the matrices used in theses operations are not
empty and returning an understandable error if it's not the case.

Related Task

closes #6930

Task: 5001658
Signed-off-by: Rémi Rahir (rar) <[email protected]>
@robodoo robodoo closed this Sep 2, 2025
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.

4 participants