Skip to content

[17.0] account_asset_management: expected singleton error in financial assets report without asset_group_id #2354

Description

@soporteitgrupolucas

Module

account_asset_management

Describe the bug

When generating the Financial Assets Report without specifying an asset_group_id, the report crashes with an Expected singleton error.

The issue occurs in version 17.0 when the code attempts to access error_dict[k].id and error_dict[k].display_name assuming that error_dict[k] contains a single record, while it may actually contain multiple account.asset records.

The traceback points to:

err_msg += "%s" % [
    x[1] for x in [(error_dict[k].id, error_dict[k].display_name)]
]

which raises:

ValueError: Expected singleton: account.asset(...)

This appears to have already been fixed in 18.0 with:

err_msg += ", ".join(error_dict[k].mapped("display_name"))

To Reproduce

Affected versions:

  • 17.0

Steps to reproduce the behavior:

  1. Install account_asset_management.
  2. Create assets belonging to different asset groups.
  3. Open the Financial Assets Report wizard.
  4. Leave the asset_group_id field empty.
  5. Generate the XLSX report.

Expected behavior

The report should be generated successfully when no asset_group_id is specified, or at least display a proper validation message.

It should not raise an Expected singleton exception when multiple assets are present in error_dict[k].

Additional context

Traceback:

Traceback (most recent call last):
  ...
  File "/opt/odoo/src/addons/oca/account-financial-tools/account_asset_management/report/account_asset_report_xls.py", line 727, in _asset_report
    x[1] for x in [(error_dict[k].id, error_dict[k].display_name)]
  File "/opt/odoo/src/odoo/odoo/fields.py", line 5187, in __get__
    raise ValueError("Expected singleton: %s" % record)
ValueError: Expected singleton: account.asset(4057, 4038, 3979, 4010, 3698, ...)

The implementation in 18.0 has already been updated to:

err_msg += ", ".join(error_dict[k].mapped("display_name"))

which correctly handles multiple records and seems to resolve the issue.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions