Skip to content

[16.0] isinstance(x, int | float) breaks on Python 3.9 in account_move_line._prepare_bg25_single_line() #74

Description

@tonygalmiche

On the 16.0 branch, account_invoice_en16931/models/account_move_line.py (lines 160 and 228) uses:

isinstance(vat_dict.get("vat_rate"), int | float)

int | float here is evaluated at runtime as the second argument of isinstance(), not just used as a type annotation. This PEP 604 union syntax between two type objects only works from Python 3.10 onwards — on Python 3.9 (still common on Odoo 16 deployments, e.g. Debian 11), it raises:

TypeError: unsupported operand type(s) for |: 'type' and 'type'

Traceback happens when generating the EN16931 XML (e.g. via generate_en16931_xml() / the Saxon test button), on any invoice line.

Suggested fix (behaviourally identical, works on all Python versions):

isinstance(vat_dict.get("vat_rate"), (int, float))

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions