Skip to content

Outgoing lifecycle flow fails with "Expected singleton: res.partner()" when the vendor bill has no partner #81

Description

@am-technix

When a vendor bill is created by l10n_fr_einvoicing_import and the supplier could not be matched, the bill has no partner_id. The automatic "in hand" event is still created, and generating its CDAR fails in fr.einvoicing.event._prepare_xml_data():

partner_siren = invoice.commercial_partner_id._get_siren(raise_if_none=True)

commercial_partner_id is an empty recordset, so _get_siren() raises Expected singleton: res.partner(). The outgoing flow goes to state error with that message in odoo_error_details, and there is nothing in it to tell the user what to do.

The two checks just below, on invoice_date and on the bill reference, both raise a UserError that says exactly what is missing and why the value was expected to be there. A missing partner seems to belong to the same family, and is arguably the most likely of the three: a supplier whose record has neither SIRET nor VAT number is not matched, and business.document.import._match_partner() returns nothing without raising, so the bill is created partner-less without any hard failure.

We had six outgoing flows in that state on our own ERP before completing the supplier records, all with the same message.

Would a UserError along the same lines as the two others be acceptable? Something like: the vendor bill has no partner, it was imported from the accredited platform, so the supplier could not be identified from the file and has to be set manually before the acknowledgement can be sent. Happy to send a PR.

Version: l10n_fr_einvoicing 18.0.1.2.0, at 6f61127.

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