Skip to content

Commit

Permalink
[ADD] l10n_es_aeat_verifactu_pos
Browse files Browse the repository at this point in the history
  • Loading branch information
ljsalvatierra-factorlibre committed Feb 9, 2025
1 parent 49b3cb0 commit eaa9766
Show file tree
Hide file tree
Showing 20 changed files with 1,587 additions and 0 deletions.
86 changes: 86 additions & 0 deletions l10n_es_aeat_verifactu_pos/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
============================
Comunicación Veri*FACTU: TPV
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:81d39ea57c7a9f59a4d558c12bff79c2f5bfb4196a14da3cd3a42f8838f7b750
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-spain/tree/16.0/l10n_es_aeat_verifactu_pos
:alt: OCA/l10n-spain
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-spain-16-0/l10n-spain-16-0-l10n_es_aeat_verifactu_pos
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-spain&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Módulo para la presentación inmediata de la facturación desde TPV.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* Refactor `retry` strategy when database is locked trying to obtain the last verifactu invoice from PoS config
* Implement stopping mechanism to avoid sending more invoices to the AEAT when there is a problem with the chain
* Implement cancelling simplified and complete invoices from the PoS
* Multiple devices per PoS Config (l10n_es_pos_by_device)
* Invoicing already sent simplified invoice (PoS Order). Send anullment for the simplified and send a new one for the complete.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-spain/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-spain/issues/new?body=module:%20l10n_es_aeat_verifactu_pos%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Factor Libre S.L.

Contributors
~~~~~~~~~~~~

* Luis J. Salvatierra <[email protected]>


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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-spain <https://github.com/OCA/l10n-spain/tree/16.0/l10n_es_aeat_verifactu_pos>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions l10n_es_aeat_verifactu_pos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
26 changes: 26 additions & 0 deletions l10n_es_aeat_verifactu_pos/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Comunicación Veri*FACTU: TPV",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"website": "https://github.com/OCA/l10n-spain",
"author": "Factor Libre S.L., Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"point_of_sale",
"l10n_es_pos",
"l10n_es_aeat_verifactu",
"pos_default_partner",
],
"assets": {
"point_of_sale.assets": [
"l10n_es_aeat_verifactu_pos/static/src/js/models.js",
"l10n_es_aeat_verifactu_pos/static/src/xml/OrderReceipt.xml",
"l10n_es_aeat_verifactu_pos/static/src/css/pos_receipts.css",
],
},
"data": [
"views/pos_order_view.xml",
],
}
4 changes: 4 additions & 0 deletions l10n_es_aeat_verifactu_pos/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import pos_session
from . import pos_config
from . import pos_order
from . import account_move
22 changes: 22 additions & 0 deletions l10n_es_aeat_verifactu_pos/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from odoo import _, exceptions, models


class AccountMove(models.Model):
_inherit = "account.move"

def _get_chaining_invoice_dict(self):
"""PoS Config has a different chain for VERI*FACTU"""
if self.pos_order_ids and len(self.pos_order_ids.ids) == 1:
# TODO: use cases
# * The Invoice is created from the PoS
# * The Invoice is created later after some time, in this case
# the PoS order (simplified invoice) is already in the chain
pos_order = self.pos_order_ids
return pos_order._get_chaining_invoice_dict()
elif len(self.pos_order_ids) > 1:
# TODO: is possible to have multiple PoS orders for the same Invoice?
raise exceptions.UserError(

Check warning on line 18 in l10n_es_aeat_verifactu_pos/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_aeat_verifactu_pos/models/account_move.py#L18

Added line #L18 was not covered by tests
_("VERI*FACTU: multiple PoS Orders not supported")
)
else:
return super()._get_chaining_invoice_dict()

Check warning on line 22 in l10n_es_aeat_verifactu_pos/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_aeat_verifactu_pos/models/account_move.py#L22

Added line #L22 was not covered by tests
28 changes: 28 additions & 0 deletions l10n_es_aeat_verifactu_pos/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from odoo import api, fields, models


class PosConfig(models.Model):
_inherit = "pos.config"

verifactu_last_invoice_id = fields.Many2one(
string="Last veri*FACTU Order sent",
comodel_name="pos.order",
copy=False,
help="Last POS order sent to veri*FACTU system for chaining purposes",
)
verifactu_base_url = fields.Char(
string="Verifactu Base URL",
compute="_compute_verifactu_base_url",
store=True,
help="Base URL for Verifactu QR code generation. Needed on PoS.",
)

@api.depends("company_id.verifactu_test")
def _compute_verifactu_base_url(self):
for record in self:
agency = self.env.ref("l10n_es_aeat.aeat_tax_agency_spain")
record.verifactu_base_url = (
agency.verifactu_qr_base_url_test_address
if record.company_id.verifactu_test
else agency.verifactu_qr_base_url
)
Loading

0 comments on commit eaa9766

Please sign in to comment.