Skip to content

Commit ba7e826

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 3b28837 commit ba7e826

11 files changed

Lines changed: 729 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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
left_results = []
17+
for invoice in left_invoices:
18+
csv = invoice["DatosPresentacion"]["CSV"]
19+
odoo_order = self.env["pos.order"].search([("sii_csv", "=", csv)])
20+
if odoo_order:
21+
matched_invoices[odoo_order] = invoice
22+
else:
23+
left_results.append(invoice)
24+
return matched_invoices, left_results
25+
26+
def _get_aeat_odoo_invoices_by_num(self, left_invoices, matched_invoices):
27+
# Try to match with PoS orders the remaining invoices by number
28+
matched_invoices, left_invoices = super()._get_aeat_odoo_invoices_by_num(
29+
left_invoices, matched_invoices
30+
)
31+
if self.invoice_type == "in":
32+
return matched_invoices, left_invoices
33+
PosOrder = self.env["pos.order"]
34+
left_results = []
35+
for invoice in left_invoices:
36+
name = invoice["IDFactura"]["NumSerieFacturaEmisor"]
37+
odoo_order = PosOrder.search(
38+
[
39+
("l10n_es_unique_id", "=", name),
40+
("state", "in", PosOrder._get_valid_document_states()),
41+
],
42+
)
43+
if odoo_order:
44+
matched_invoices[odoo_order] = invoice
45+
else:
46+
left_results.append(invoice)
47+
return matched_invoices, left_results
48+
49+
def _get_not_in_sii_invoices(self, invoices):
50+
# Add the PoS orders not in SII
51+
res = super()._get_not_in_sii_invoices(invoices)
52+
if self.invoice_type == "in":
53+
return res
54+
date_start, date_end = self._get_date_interval()
55+
prev_order_ids = [x.id for x in invoices.keys() if x._name == "pos.order"]
56+
domain = [
57+
("id", "not in", prev_order_ids),
58+
("date_order", ">=", date_start),
59+
("date_order", "<", date_end),
60+
("company_id", "=", self.company_id.id),
61+
("sii_enabled", "=", True),
62+
]
63+
for order in self.env["pos.order"].search(domain):
64+
res.append(order._get_match_report_values(False))
65+
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
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)