How Odoo identifies a foreign customer
The module decides the identifier type when the invoice is posted, using two fields of the contact: the country and the tax ID (Odoo's VAT field).
- Customer with country Spain, or no country
- Sent in the NIF field. If the number starts with X, Y or Z, it is treated as an NIE, the ID of foreign residents.
- Customer from another EU country
- Sent in IDOtro with IDType 02 (EU VAT number) and no CodigoPais.
- Customer from outside the EU
- Sent in IDOtro with the CodigoPais of their country and IDType 04, or IDType 03 (passport) if the number has more than 20 characters or none that are alphanumeric.
The number travels with 20 characters at most. With this in mind, almost every code below is explained by two fields of the contact: country and tax ID.

The codes, one by one
The AEAT texts are in Spanish; the right column says what each one points at.
| Code | What the AEAT says, in short | What to check |
|---|---|---|
| 1239 | Error en el bloque Destinatario. | The whole block: country, tax ID and name of the contact. |
| 1101 | El valor del campo CodigoPais es incorrecto. | The contact's country. |
| 1102 | El valor del campo IDType es incorrecto. | The document type that was inferred. |
| 1103 | El valor del campo ID es incorrecto. | The contact's number. |
| 1111 | CodigoPais is mandatory when IDType is not 02. | A customer with no country in Odoo. |
| 1122 | CodigoPais does not match the first two characters of the number. | A number with another country's prefix. |
| 1126 | CodigoPais ES only with IDType 03 or 07. | A Spanish customer sent through IDOtro. |
| 1131 | With IDType 07 the number must be the NIF of an individual. | Type 07, which the module does not use. |
| 1222 | El valor del campo ID del bloque IDOtro es incorrecto. | The number of a foreign customer. |
| 1232, 1233 and 1234 | IDOtro with CodigoPais ES requires IDType 03, 07 or one of the two. | Spain as country on a passport customer. |
| 1254 and 1255 | UK VAT numbers: XI is not accepted before 01/01/2021 and GB is not accepted from 01/02/2021. | The operation date and the prefix. |
For IDType 02 the AEAT also checks that the number has the EU VAT structure of the member state and is in capitals. In practice, a European customer's tax ID has to be stored in Odoo with its country prefix, as VIES validates it.
What happens in Odoo when the AEAT rejects it
These codes reject the record, not the submission: the other invoices in the same request go through. The queue puts the rejected one in Retrying and sends it again with growing waits, from 2 minutes to 12 hours; on the sixth attempt it moves to Dead Letter and the record becomes «Error permanente» (permanent error).

Retrying changes nothing if the data is wrong, because the submission is built from the record created when the invoice was posted, not from the contact. That is why the fix has two parts:
- Correct the country or tax ID of the contact, so that the next invoices go out right.
- For the invoice already rejected, the AEAT provides a «registration after rejection», with Subsanacion S and RechazoPrevio X. The published module does not generate that record on its own: write to comercial@flexigobe.com with the invoice number and we will sort it out with you.
The codes on this page, with the AEAT's text
Each code with its literal text, in Spanish, as the AEAT's error list gives it:
| Code | AEAT text (Spanish) |
|---|---|
| 1239 | Error en el bloque Destinatario. |
| 1101 | El valor del campo CodigoPais es incorrecto. |
| 1102 | El valor del campo IDType es incorrecto. |
| 1103 | El valor del campo ID es incorrecto. |
| 1111 | El campo CodigoPais es obligatorio cuando IDType es distinto de NIF-IVA (02). |
| 1122 | El campo CodigoPais indicado no coincide con los dos primeros dígitos del identificador. |
| 1126 | El valor del CodigoPais solo puede ser ES cuando el IDType sea Pasaporte (03) o No Censado (07). Si IDType es No Censado (07) el CodigoPais debe ser ES (España). |
| 1131 | El valor del campo ID ha de ser el NIF de una persona física cuando el campo IDType tiene valor No Censado (07). |
| 1222 | El valor del campo ID del bloque IDOtro es incorrecto. |
| 1232 | Si se identifica a través de la agrupación IDOtro y CodigoPais tiene valor ES (España), el campo IDType debe valer Pasaporte (03). |
| 1233 | Si se identifica a través de la agrupación IDOtro y CodigoPais tiene valor ES (España), el campo IDType debe valer No Censado (07). |
| 1234 | Si se identifica a través de la agrupación IDOtro y CodigoPais tiene valor ES (España), el campo IDType debe valer Pasaporte (03) o No Censado (07). |
| 1254 | Si FechaOperacion (FechaExpedicionFactura si no se informa FechaOperacion) es anterior a 01/01/2021 no se permite el valor 'XI' para Identificaciones NIF-IVA |
| 1255 | Si FechaOperacion (FechaExpedicionFactura si no se informa FechaOperacion) es mayor o igual que 01/02/2021 no se permite el valor 'GB' para Identificaciones NIF-IVA |
If the code you see is not in this table, the full catalogue is in AEAT Submission › AEAT Error Catalogue, with the literal AEAT text.
Keep reading
Checked in the module's source code (version 20.0) and the linked sources
Sources
- www.agenciatributaria.es/static_files/AEAT_Desarrolladores/EEDD/IVA/VERI-FACTU/Validacione
- Module source code: flexigo_spain_verifactu 20.0 (aa2ea3d2): models/verifactu_cadena.py
- Module source code: flexigo_spain_verifactu 20.0 (aa2ea3d2): models/verifactu_aeat_client.py
- Module source code: flexigo_spain_verifactu 20.0 (aa2ea3d2): models/verifactu_cola_envio.py
- Module source code: flexigo_spain_verifactu 20.0 (aa2ea3d2): models/verifactu_registro.py
- Module source code: flexigo_spain_verifactu 20.0 (aa2ea3d2): data/verifactu_error_catalogue.xml
- prewww2.aeat.es/static_files/common/internet/dep/aplicaciones/es/aeat/tikeV1.0/cont/ws/err
