Skip to content

Commit 479d53a

Browse files
pedrobaezavictoralmau
authored andcommitted
[ADD] l10n_es_pos_sii_match: Glue module for l10n_es_aeat_sii_match and l10n_es_pos_sii
It adds to the contrast the PoS orders.
1 parent 811bf03 commit 479d53a

13 files changed

Lines changed: 753 additions & 28 deletions

File tree

l10n_es_aeat_sii_match/README.rst

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ Sistema de comprobación y contraste de facturas enviadas al SII
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

31-
- El módulo recupera los datos enviados a la AEAT mediante peticiones
32-
unitarias o por meses (como una declaración AEAT)
33-
- Los datos recibidos se procesan intentando asociarlos mediante su CSV
34-
(Código Seguro de Verificación) y si no encuentra el CSV, busca por
35-
número de factura/fecha/partner
36-
- El módulo muestra aquellos registros que no han conseguido asociarse,
37-
así como aquellas facturas en Odoo que no tienen su correspondiente
38-
registro en los datos recibidos.
39-
- En segundo lugar se exponen los registros que tienen diferencias entre
40-
Odoo y AEAT
41-
- Por último se muestran por separado facturas 'No contrastadas' o
42-
'Parcialmente contrastadas', es decir, las que la propia AEAT no haya
43-
podido cotejar entre el emisor de la factura y el receptor, siendo los
44-
dos obligados a declarar en el sistema SII.
31+
- El módulo recupera los datos enviados a la AEAT mediante peticiones
32+
unitarias o por meses (como una declaración AEAT)
33+
- Los datos recibidos se procesan intentando asociarlos mediante su CSV
34+
(Código Seguro de Verificación) y si no encuentra el CSV, busca por
35+
número de factura/fecha/partner
36+
- El módulo muestra aquellos registros que no han conseguido asociarse,
37+
así como aquellas facturas en Odoo que no tienen su correspondiente
38+
registro en los datos recibidos.
39+
- En segundo lugar se exponen los registros que tienen diferencias
40+
entre Odoo y AEAT
41+
- Por último se muestran por separado facturas 'No contrastadas' o
42+
'Parcialmente contrastadas', es decir, las que la propia AEAT no haya
43+
podido cotejar entre el emisor de la factura y el receptor, siendo
44+
los dos obligados a declarar en el sistema SII.
4545

4646
**Table of contents**
4747

@@ -70,19 +70,19 @@ Authors
7070
Contributors
7171
------------
7272

73-
- `Studio73 <https://www.studio73.es>`__
73+
- `Studio73 <https://www.studio73.es>`__
7474

75-
- Abraham Anes
76-
- Pablo Fuentes
77-
- Jordi Tolsá
78-
- Guillermo Llinares
79-
- Carlos Reyes
75+
- Abraham Anes
76+
- Pablo Fuentes
77+
- Jordi Tolsá
78+
- Guillermo Llinares
79+
- Carlos Reyes
8080

81-
- `Tecnativa <https://www.tecnativa.com>`__:
81+
- `Tecnativa <https://www.tecnativa.com>`__:
8282

83-
- Víctor Martínez
84-
- David Bañón Gil
85-
- Pedro M. Baeza
83+
- Víctor Martínez
84+
- David Bañón Gil
85+
- Pedro M. Baeza
8686

8787
Maintainers
8888
-----------

l10n_es_aeat_sii_match/static/description/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,12 @@ <h1 class="title">Sistema de comprobación y contraste de facturas enviadas al S
379379
<li>El módulo muestra aquellos registros que no han conseguido asociarse,
380380
así como aquellas facturas en Odoo que no tienen su correspondiente
381381
registro en los datos recibidos.</li>
382-
<li>En segundo lugar se exponen los registros que tienen diferencias entre
383-
Odoo y AEAT</li>
382+
<li>En segundo lugar se exponen los registros que tienen diferencias
383+
entre Odoo y AEAT</li>
384384
<li>Por último se muestran por separado facturas ‘No contrastadas’ o
385385
‘Parcialmente contrastadas’, es decir, las que la propia AEAT no haya
386-
podido cotejar entre el emisor de la factura y el receptor, siendo los
387-
dos obligados a declarar en el sistema SII.</li>
386+
podido cotejar entre el emisor de la factura y el receptor, siendo
387+
los dos obligados a declarar en el sistema SII.</li>
388388
</ul>
389389
<p><strong>Table of contents</strong></p>
390390
<div class="contents local topic" id="contents">

l10n_es_pos_sii_match/README.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
=======================================
2+
Extensión del contraste SII para el TPV
3+
=======================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:78672c445bd38e613a4e94b233441d00a179e5625c89109b7033b37ebfcb1166
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github
20+
:target: https://github.com/OCA/l10n-spain/tree/18.0/l10n_es_pos_sii_match
21+
:alt: OCA/l10n-spain
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/l10n-spain-18-0/l10n-spain-18-0-l10n_es_pos_sii_match
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-spain&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Extensión del módulo base de contraste del SII para contrastar también
32+
los pedidos del TPV enviados al SII.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Bug Tracker
40+
===========
41+
42+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-spain/issues>`_.
43+
In case of trouble, please check there if your issue has already been reported.
44+
If you spotted it first, help us to smash it by providing a detailed and welcomed
45+
`feedback <https://github.com/OCA/l10n-spain/issues/new?body=module:%20l10n_es_pos_sii_match%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
46+
47+
Do not contact contributors directly about support or help with technical issues.
48+
49+
Credits
50+
=======
51+
52+
Authors
53+
-------
54+
55+
* Tecnativa
56+
57+
Contributors
58+
------------
59+
60+
- `Tecnativa <https://www.tecnativa.com>`__:
61+
62+
- Pedro M. Baeza
63+
64+
Maintainers
65+
-----------
66+
67+
This module is maintained by the OCA.
68+
69+
.. image:: https://odoo-community.org/logo.png
70+
:alt: Odoo Community Association
71+
:target: https://odoo-community.org
72+
73+
OCA, or the Odoo Community Association, is a nonprofit organization whose
74+
mission is to support the collaborative development of Odoo features and
75+
promote its widespread use.
76+
77+
.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px
78+
:target: https://github.com/pedrobaeza
79+
:alt: pedrobaeza
80+
81+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
82+
83+
|maintainer-pedrobaeza|
84+
85+
This module is part of the `OCA/l10n-spain <https://github.com/OCA/l10n-spain/tree/18.0/l10n_es_pos_sii_match>`_ project on GitHub.
86+
87+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

l10n_es_pos_sii_match/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2026 Tecnativa - Pedro M. Baeza
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Extensión del contraste SII para el TPV",
5+
"version": "18.0.1.0.0",
6+
"category": "Accounting & Finance",
7+
"website": "https://github.com/OCA/l10n-spain",
8+
"author": "Tecnativa, Odoo Community Association (OCA)",
9+
"license": "AGPL-3",
10+
"depends": ["l10n_es_pos_sii", "l10n_es_aeat_sii_match"],
11+
"data": ["views/pos_order_views.xml"],
12+
"auto_install": True,
13+
"installable": True,
14+
"maintainers": ["pedrobaeza"],
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import aeat_sii_match_report
2+
from . import pos_order
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2026 Tecnativa - Pedro M. Baeza
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from odoo import models
4+
5+
6+
class SiiMatchReport(models.Model):
7+
_inherit = "l10n.es.aeat.sii.match.report"
8+
9+
def _get_aeat_odoo_invoices_by_csv(self, sii_response):
10+
# Try to match with PoS orders the remaining invoices by CSV
11+
matched_invoices, left_invoices = super()._get_aeat_odoo_invoices_by_csv(
12+
sii_response
13+
)
14+
if self.invoice_type == "in":
15+
return matched_invoices, left_invoices
16+
for invoice in left_invoices:
17+
csv = invoice["DatosPresentacion"]["CSV"]
18+
odoo_order = self.env["pos.order"].search([("sii_csv", "=", csv)])
19+
if odoo_order:
20+
matched_invoices[odoo_order] = invoice
21+
left_invoices.remove(invoice)
22+
return matched_invoices, left_invoices
23+
24+
def _get_aeat_odoo_invoices_by_num(self, left_invoices, matched_invoices):
25+
# Try to match with PoS orders the remaining invoices by number
26+
matched_invoices, left_invoices = super()._get_aeat_odoo_invoices_by_num(
27+
left_invoices, matched_invoices
28+
)
29+
if self.invoice_type == "in":
30+
return matched_invoices, left_invoices
31+
PosOrder = self.env["pos.order"]
32+
for invoice in left_invoices:
33+
name = invoice["IDFactura"]["NumSerieFacturaEmisor"]
34+
odoo_order = PosOrder.search(
35+
[
36+
("l10n_es_unique_id", "=", name),
37+
("state", "in", PosOrder._get_valid_document_states()),
38+
],
39+
)
40+
if odoo_order:
41+
matched_invoices[odoo_order] = invoice
42+
left_invoices.remove(invoice)
43+
return matched_invoices, left_invoices
44+
45+
def _get_not_in_sii_invoices(self, invoices):
46+
# Add the PoS orders not in SII
47+
res = super()._get_not_in_sii_invoices(invoices)
48+
if self.invoice_type == "in":
49+
return res
50+
date_start, date_end = self._get_date_interval()
51+
prev_order_ids = [x.id for x in invoices.keys() if x._name == "pos.order"]
52+
domain = [
53+
("id", "not in", prev_order_ids),
54+
("date_order", ">=", date_start),
55+
("date_order", "<", date_end),
56+
("company_id", "=", self.company_id.id),
57+
("sii_enabled", "=", True),
58+
]
59+
for order in self.env["pos.order"].search(domain):
60+
res.append(order._get_match_report_values(False))
61+
return res
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2026 Tecnativa - Pedro M. Baeza
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, exceptions, fields, models
5+
6+
7+
class PosOder(models.Model):
8+
_inherit = "pos.order"
9+
10+
# It is necessary to define a group to prevent point_of_sale at
11+
# https://github.com/odoo/odoo/blob/404b839566fbc1a72d3e68c7a02ddbfa3b18980d/addons/point_of_sale/models/pos_order.py# L1166 # noqa: E501
12+
# from returning an error when attempting to access the
13+
# l10n.es.aeat.sii.match.difference model of the field if the user does not have
14+
# sufficient permissions.
15+
sii_match_difference_ids = fields.One2many(groups="l10n_es_aeat.group_account_aeat")
16+
17+
def contrast_aeat(self):
18+
invalid_orders = self.filtered(
19+
lambda x: not x.sii_enabled or x.aeat_state != "sent"
20+
)
21+
if invalid_orders:
22+
raise exceptions.UserError(
23+
_(
24+
"The orders must be sent to SII in order to be matched."
25+
"\nNon-matchable orders: %(order_names)s",
26+
order_names=", ".join(i.name for i in invalid_orders),
27+
)
28+
)
29+
return super().contrast_aeat()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
- [Tecnativa](https://www.tecnativa.com):
3+
- Pedro M. Baeza

0 commit comments

Comments
 (0)