Skip to content

Commit 4f2ff87

Browse files
committed
[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 05e2ab3 commit 4f2ff87

11 files changed

Lines changed: 720 additions & 0 deletions

File tree

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: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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(
61+
{
62+
"invoice": order._get_document_serial_number(),
63+
"invoice_id": order.id,
64+
"model": order._name,
65+
"sii_contrast_state": "no_exist",
66+
"invoice_location": "odoo",
67+
}
68+
)
69+
return res
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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, models
5+
6+
7+
class PosOder(models.Model):
8+
_inherit = "pos.order"
9+
10+
def contrast_aeat(self):
11+
invalid_orders = self.filtered(
12+
lambda x: not x.sii_enabled or x.aeat_state != "sent"
13+
)
14+
if invalid_orders:
15+
raise exceptions.UserError(
16+
_(
17+
"The orders must be sent to SII in order to be matched."
18+
"\nNon-matchable orders: %(order_names)s",
19+
order_names=", ".join(i.name for i in invalid_orders),
20+
)
21+
)
22+
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
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Extensión del módulo base de contraste del SII para contrastar también los pedidos del
2+
TPV enviados al SII.

0 commit comments

Comments
 (0)