addons-cm/l10n_es_edi_tbai_reagyp_recibidas
GitHub Copilot 8bf9779d98 [FIX] l10n_es_edi_tbai_reagyp_recibidas: fix chaining within same invoice series
TicketBAI maintains independent chains per invoice series (INV, RINV, etc).
When building the chain for a new invoice, ensure it links to the previous
valid document from the same series, not just the last document regardless
of series.

Fixes error "time data '' does not match format '%d-%m-%Y'" when previous
document's XML is missing or when wrong series document is used for chaining.

- Override _get_sale_values to validate series match
- Add _get_last_chained_document_by_series to filter by series+state+xml
- Skip cancelled documents and documents without valid XML

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-31 18:48:58 +02:00
..
models [FIX] l10n_es_edi_tbai_reagyp_recibidas: fix chaining within same invoice series 2026-07-31 18:48:58 +02:00
static/description [IMP] l10n_es_edi_tbai_reagyp_recibidas: add Criptomart module icon 2026-05-25 14:18:46 +02:00
__init__.py [ADD] l10n_es_edi_tbai_reagyp_recibidas: fix REAGYP vendor bill regime key 2026-05-25 14:12:16 +02:00
__manifest__.py [ADD] l10n_es_edi_tbai_reagyp_recibidas: fix REAGYP vendor bill regime key 2026-05-25 14:12:16 +02:00
README.rst [ADD] l10n_es_edi_tbai_reagyp_recibidas: fix REAGYP vendor bill regime key 2026-05-25 14:12:16 +02:00

===================================
TicketBAI REAGYP Facturas Recibidas
===================================

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3

|badge1| |badge2|

This module fixes a bug in the native Odoo ``l10n_es_edi_tbai`` module when
sending vendor bills under the special agriculture regime (REAGYP) to Batuz
(Bizkaia LROE).

**Problem Solved:**

For REAGYP vendor bills, ``l10n_es_edi_tbai`` hardcodes the regime key
``ClaveRegimenIvaOpTrascendencia`` to ``19``. Key ``19`` only exists in the
issued-invoices book; the received-invoices (FacturasRecibidas) schema rejects
it with::

    cvc-enumeration-valid: Value '19' is not facet-valid with respect to
    enumeration '[01, 02, 03, 04, 05, 06, 07, 08, 09, 12, 13]'

The correct key for REAGYP compensations on purchases is ``02``.

**Solution:**

Overrides ``account.move._l10n_es_tbai_get_vendor_bill_values_batuz`` to remap
the regime key from ``19`` to ``02`` for received invoices. The override is
defensive: it only acts when the value is exactly ``['19']``, so it becomes a
no-op once the upstream fix lands.

Upstream tracking: https://github.com/odoo/odoo/pull/266214

Bug Tracker
===========

Report issues at https://git.criptomart.net/criptomart/addons-cm

Credits
=======

Authors
~~~~~~~

* Criptomart

Maintainers
~~~~~~~~~~~

This module is maintained by Criptomart.