Skip to content

[18.0] account_invoice_facturx: BR-FX-EN-04 Schematron failure - BT-72 (delivery date) missing from CII-XML #1321

Open

Description

@MartinHeisig

Bug Description

_cii_add_trade_delivery_block() in account_invoice_facturx builds the
ApplicableHeaderTradeDelivery block but never writes the
ActualDeliverySupplyChainEvent element (BT-72). The field delivery_date
on account.move is not read anywhere in the CII-XML generation.

This causes every PDF download of a non-downpayment invoice to fail with HTTP 500.

Error:

Exception: The Factur-X XML file is not valid against the official schematron. 1 errors found:
[BR-FX-EN-04]-An invoice that is not a down payment invoice (code 386) must contain
either BT-72 "Actual delivery date", BG-14 "Invoicing period" or BG-26 "Invoice line
period" in each invoice item to indicate the delivery/service date.

File: account_invoice_facturx/models/account_move.py, line 270

Current Code (broken)

def _cii_add_trade_delivery_block(self, trade_transaction, ns):
    self.ensure_one()
    trade_agreement = etree.SubElement(
        trade_transaction, ns["ram"] + "ApplicableHeaderTradeDelivery"
    )
    if self.partner_shipping_id:
        shipto_trade_party = etree.SubElement(
            trade_agreement, ns["ram"] + "ShipToTradeParty"
        )
        self._cii_add_address_block(
            self.partner_shipping_id, shipto_trade_party, ns
        )
    return trade_agreement  # <-- ActualDeliverySupplyChainEvent (BT-72) never written

Proposed Fix

def _cii_add_trade_delivery_block(self, trade_transaction, ns):
    self.ensure_one()
    trade_agreement = etree.SubElement(
        trade_transaction, ns["ram"] + "ApplicableHeaderTradeDelivery"
    )
    if self.partner_shipping_id:
        shipto_trade_party = etree.SubElement(
            trade_agreement, ns["ram"] + "ShipToTradeParty"
        )
        self._cii_add_address_block(
            self.partner_shipping_id, shipto_trade_party, ns
        )
    # BT-72: Actual delivery date — required by BR-FX-EN-04
    # Fall back to invoice_date when delivery_date is not explicitly set
    delivery_date = self.delivery_date or self.invoice_date
    if delivery_date:
        actual_delivery = etree.SubElement(
            trade_agreement,
            ns["ram"] + "ActualDeliverySupplyChainEvent",
        )
        self._cii_add_date("OccurrenceDateTime", delivery_date, actual_delivery, ns)
    return trade_agreement

Environment

  • Odoo version: 18.0
  • account_invoice_facturx repository: 18.0 branch (as of 2026-04-08, no fix in repo)

Activity

  1. pc-technik commented on May 7, 2026

    @pc-technik

    Odoo version: 18.0-20260429 (Community Edition)

    After trying the fix, i receive the following error:

    AttributeError: 'account.move' object has no attribute 'regular_pdf_invoice_to_facturx_invoice'

  2. MartinHeisig commented on May 7, 2026

    @MartinHeisig
    Author

    Odoo version: 18.0-20260429 (Community Edition)

    After trying the fix, i receive the following error:

    AttributeError: 'account.move' object has no attribute 'regular_pdf_invoice_to_facturx_invoice'

    Your error seems not to be caused by the proposed fix. regular_pdf_invoice_to_facturx_invoice is part
    of the original account_invoice_facturx module itself (defined in models/account_move.py, lines 1056–1077) — the fix only touches
    _cii_add_trade_delivery_block, which is a completely separate method with no relation to the missing attribute.

    If that attribute is missing on account.move, account_invoice_facturx may not be installed or loaded correctly.

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