diff --git a/l10n_es_facturae_face/README.rst b/l10n_es_facturae_face/README.rst new file mode 100644 index 00000000000..f6f7791aa98 --- /dev/null +++ b/l10n_es_facturae_face/README.rst @@ -0,0 +1,172 @@ +======================== +Envío de Facturae a FACe +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:cb5acc786d5d80c239ec646278ab331b1c28813e7d219a9e85a8a8294ed9717d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/l10n_es_facturae_face + :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-17-0/l10n-spain-17-0-l10n_es_facturae_face + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Este módulo permite la gestión del envío de la facturación electrónica +española a FACe. La gestión del envío se realiza mediante los +certificados con los que se firma. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +- Es necesario añadir el correo electrónico al que notificar los + cambios de estado en la empresa +- Se debe configurar el servidor de envío +- Por defecto se añado el servicio web de test: + https://se-face-webservice.redsara.es/facturasspp2 +- Si queremos añadir el de producción, debemos cambiar el parámetro por + https://webservice.face.gob.es/facturasspp2 y modificar el + certificado en parámetros de sistema + +Para poder enviar correctamente, debemos subir el certificado al entorno +correspondiente, para ello, accederemos a https://face.gob.es +(Producción) o https://se-face.redsara.es (Desarrollo). Allí, +accederemos a Integradores/Gestión de certificados y nos loguearemos con +Certificado Electrónico. Una vez dentro, debemos darnos de alta como +integrador creando una incidencia en la URL que nos aparecerá. El +siguiente +`documento `__ +tiene toda la información detallada. + +Cuando nos confirmen el alta, será necesario subir la parte pública de +nuestro certificado, un comando para exportarlo es: + +.. code:: bash + + openssl pkcs12 -in MI_CERTIFICADO.pfx -out MI_CERTIFICADO.crt -nokeys -clcerts + cat MI_CERTIFICADO.crt + +Deberemos añadir toda la parte entre -----BEGIN CERTIFICATE----- y +-----END CERTIFICATE----- incluidos ambos. + +Usage +===== + +Configurar clientes +------------------- + +- Accedemos a un cliente + + - Le configuramos la opción de factura electrónica y rellenamos los + datos obligatorios + - Marcamos como método de envío FACe + +- A partir de este momento, todas las facturas que validemos del + cliente se enviarán automáticamente a no ser que marquemos la opción + de Deshabilitar envío EDI + +Envío de facturas +----------------- + +- Cuando validemos una factura de un cliente configurado a enviar por + FACe se creará un registro de Envío EDI +- Mediante un job, se generarán los datos necesarios y, posteriormente, + se enviará como un registro EDI estándar +- Una vez se envíe, se alamacenará en la factura el resultado y el + número de registro +- Tras eso, podremos actualizar el estado de forma online presionando + el botón Actualizar Estado FACe +- Además, también podremos solicitar la anulación de la factura + pulsando 'Cancelar Envío' e introduciendo el motivo + +Es importante tener en cuenta que: + +- Un registro Enviado correctamente no puede ser Eliminado +- Sólo puede existir un envío Enviado correctamente (no cancelado) +- Se genera una tarea programada que actualiza los registros enviados + correctamente no pagados y no anulados +- En caso de que se anule la factura por parte del cliente, podremos + reenviarla de nuevo + +Envío manual de facturas +------------------------ + +- Esto podría pasarnos con facturas antiguas en las que configuramos el + cliente tras emitir la factura o en las que hemos deshabilitado el + envío automático +- Accedemos a una factura validada del cliente no enviada y pulsamos el + botón 'Spanish Facturae'. En caso de salirnos una opción de elección, + deberemos seleccionara FACe +- Tras esto, funcionará de la misma forma que un envío estándar + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Creu Blanca + +Contributors +------------ + +- Enric Tobella +- Eric Antones +- Manuel Regidor +- Valentín Vinagre + +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. + +.. |maintainer-etobella| image:: https://github.com/etobella.png?size=40px + :target: https://github.com/etobella + :alt: etobella + +Current `maintainer `__: + +|maintainer-etobella| + +This module is part of the `OCA/l10n-spain `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_es_facturae_face/__init__.py b/l10n_es_facturae_face/__init__.py new file mode 100644 index 00000000000..2a610734a28 --- /dev/null +++ b/l10n_es_facturae_face/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import components +from . import models +from . import wizards diff --git a/l10n_es_facturae_face/__manifest__.py b/l10n_es_facturae_face/__manifest__.py new file mode 100644 index 00000000000..d00d2c08211 --- /dev/null +++ b/l10n_es_facturae_face/__manifest__.py @@ -0,0 +1,30 @@ +# © 2017 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Envío de Facturae a FACe", + "version": "17.0.1.0.0", + "author": "Creu Blanca, Odoo Community Association (OCA)", + "category": "Accounting & Finance", + "website": "https://github.com/OCA/l10n-spain", + "license": "AGPL-3", + "depends": [ + "l10n_es_facturae", + "edi_account_oca", + "edi_exchange_template_oca", + ], + "data": [ + "security/ir.model.access.csv", + "data/edi.xml", + "data/face_data.xml", + "data/cron_data.xml", + "wizards/edi_l10n_es_facturae_face_cancel.xml", + "views/account_move.xml", + "views/res_company_view.xml", + "views/res_partner.xml", + "views/edi_exchange_record.xml", + ], + "external_dependencies": {"python": ["zeep", "cryptography==3.4.8"]}, + "installable": True, + "maintainers": ["etobella"], +} diff --git a/l10n_es_facturae_face/components/__init__.py b/l10n_es_facturae_face/components/__init__.py new file mode 100644 index 00000000000..024795b27e6 --- /dev/null +++ b/l10n_es_facturae_face/components/__init__.py @@ -0,0 +1,7 @@ +from . import webservice_face +from . import account_move_l10n_es_facturae_listener +from . import edi_send_l10n_es_facturae_face +from . import account_move_l10n_es_facturae_face_listener +from . import edi_webservice_receive_face_l10n_es_facturae_face_update +from . import edi_input_process_l10n_es_facturae_l10n_es_facturae_face_update +from . import edi_send_l10n_es_facturae_face_cancel diff --git a/l10n_es_facturae_face/components/account_move_l10n_es_facturae_face_listener.py b/l10n_es_facturae_face/components/account_move_l10n_es_facturae_face_listener.py new file mode 100644 index 00000000000..b5b840294c0 --- /dev/null +++ b/l10n_es_facturae_face/components/account_move_l10n_es_facturae_face_listener.py @@ -0,0 +1,34 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _ +from odoo.exceptions import UserError + +from odoo.addons.component.core import Component + + +class AccountMoveL10nEsFacturaeFACeListener(Component): + _name = "account.move.l10n.es.facturae.face.listener" + _inherit = "base.event.listener" + _apply_on = ["account.move"] + + def on_edi_generate_manual(self, move, exchange_record): + if exchange_record.type_id.code != "l10n_es_facturae_face_update": + return + related_record = move._get_exchange_record( + self.env.ref("l10n_es_facturae_face.facturae_exchange_type"), + self.env.ref("l10n_es_facturae_face.face_backend"), + ) + if not related_record: + raise UserError(_("Exchange record cannot be found for FACe")) + if exchange_record.edi_exchange_state == "new": + exchange_record.write( + {"edi_exchange_state": "input_pending", "parent_id": related_record.id} + ) + exchange_record.backend_id.with_context( + _edi_send_break_on_error=True + ).exchange_receive(exchange_record) + exchange_record.backend_id.with_context( + _edi_send_break_on_error=True + ).exchange_process(exchange_record) diff --git a/l10n_es_facturae_face/components/account_move_l10n_es_facturae_listener.py b/l10n_es_facturae_face/components/account_move_l10n_es_facturae_listener.py new file mode 100644 index 00000000000..8cf02e46b28 --- /dev/null +++ b/l10n_es_facturae_face/components/account_move_l10n_es_facturae_listener.py @@ -0,0 +1,46 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.component.core import Component + + +class AccountMoveL10nEsFacturaeListener(Component): + _name = "account.move.l10n.es.facturae.listener" + _inherit = "base.event.listener" + _apply_on = ["account.move"] + + def _get_backend(self, record): + return self.env.ref("l10n_es_facturae_face.face_backend") + + def _get_exchange_record_vals(self, record): + return { + "model": record._name, + "res_id": record.id, + } + + def on_post_account_move(self, records): + for record in records: + if record.edi_disable_auto: + continue + partner = record.partner_id + if record.move_type not in ["out_invoice", "out_refund"]: + continue + if not partner.facturae or not partner.l10n_es_facturae_sending_code: + continue + backend = self._get_backend(record) + if not backend: + continue + exchange_type = self.env.ref("l10n_es_facturae_face.facturae_exchange_type") + # We check fields now to raise an error to the user, otherwise the + # error will be raising silently in the queue job. + record.validate_facturae_fields() + if record._has_exchange_record(exchange_type, backend): + continue + exchange_record = backend.create_record( + exchange_type.code, self._get_exchange_record_vals(record) + ) + exchange_record.with_delay().action_exchange_generate() + + def on_generate_account_edi(self, records): + return self.on_post_account_move(records) diff --git a/l10n_es_facturae_face/components/edi_input_process_l10n_es_facturae_l10n_es_facturae_face_update.py b/l10n_es_facturae_face/components/edi_input_process_l10n_es_facturae_l10n_es_facturae_face_update.py new file mode 100644 index 00000000000..365a0389bca --- /dev/null +++ b/l10n_es_facturae_face/components/edi_input_process_l10n_es_facturae_l10n_es_facturae_face_update.py @@ -0,0 +1,41 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json + +from odoo.addons.component.core import Component + + +class EdiInputProcessL10nEsFacturaeFaceUpdate(Component): + _name = "edi.input.process.l10n_es_facturae.l10n_es_facturae_face_update" + _usage = "input.process" + _backend_type = "l10n_es_facturae" + _exchange_type = "l10n_es_facturae_face_update" + + _inherit = "edi.component.input.mixin" + + def process(self): + data = json.loads(self.exchange_record._get_file_content()) + parent = self.exchange_record.parent_id + process_code = "face-" + data["tramitacion"]["codigo"] + revocation_code = "face-" + data["anulacion"]["codigo"] + if ( + process_code == parent.l10n_es_facturae_status + and revocation_code == parent.l10n_es_facturae_cancellation_status + ): + return + parent.write( + { + "l10n_es_facturae_status": process_code, + "l10n_es_facturae_motive": data["tramitacion"]["motivo"], + "l10n_es_facturae_cancellation_status": revocation_code, + "l10n_es_facturae_cancellation_motive": data["anulacion"]["motivo"], + } + ) + self.exchange_record.record.write( + { + "l10n_es_facturae_status": process_code, + "l10n_es_facturae_cancellation_status": revocation_code, + } + ) diff --git a/l10n_es_facturae_face/components/edi_send_l10n_es_facturae_face.py b/l10n_es_facturae_face/components/edi_send_l10n_es_facturae_face.py new file mode 100644 index 00000000000..cbf672b4ed9 --- /dev/null +++ b/l10n_es_facturae_face/components/edi_send_l10n_es_facturae_face.py @@ -0,0 +1,33 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.component.core import Component + + +class EdiOutputSendL10nEsFacturaeFace(Component): + _name = "edi.output.send.l10n_es_facturae.l10n_es_facturae_face_output" + _usage = "output.send" + _backend_type = "l10n_es_facturae" + _exchange_type = "l10n_es_facturae" + _inherit = ["edi.component.send.mixin", "base.webservice.face"] + + def _get_extra_attachment(self): + return [] + + def send(self): + invoice = self.exchange_record.record + public_crt, private_key = self.env["l10n.es.aeat.certificate"].get_certificates( + invoice.company_id + ) + response = self.send_webservice( + public_crt, + private_key, + self.exchange_record._get_file_content(), + self.exchange_record.exchange_filename, + invoice.company_id.face_email, + self._get_extra_attachment(), + ) + self.exchange_record.write( + {"external_identifier": response.factura.numeroRegistro} + ) diff --git a/l10n_es_facturae_face/components/edi_send_l10n_es_facturae_face_cancel.py b/l10n_es_facturae_face/components/edi_send_l10n_es_facturae_face_cancel.py new file mode 100644 index 00000000000..392a0258ef9 --- /dev/null +++ b/l10n_es_facturae_face/components/edi_send_l10n_es_facturae_face_cancel.py @@ -0,0 +1,33 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json + +from odoo.addons.component.core import Component + + +class EdiOutputSendL10nEsFacturaeFace(Component): + _name = "edi.output.send.l10n_es_facturae.l10n_es_facturae_face_cancel_output" + _usage = "output.send" + _backend_type = "l10n_es_facturae" + _exchange_type = "l10n_es_facturae_face_cancel" + _inherit = ["edi.component.send.mixin", "base.webservice.face"] + + def send(self): + move = self.exchange_record.record + parent = self.exchange_record.parent_id + data = json.loads(self.exchange_record._get_file_content()) + public_crt, private_key = self.env["l10n.es.aeat.certificate"].get_certificates( + move.company_id + ) + self.cancel( + public_crt, + private_key, + parent.external_identifier, + data["motive"], + ) + cancellation_status = "face-4200" + parent.l10n_es_facturae_cancellation_status = cancellation_status + move.l10n_es_facturae_cancellation_status = cancellation_status + parent.l10n_es_facturae_cancellation_motive = data["motive"] diff --git a/l10n_es_facturae_face/components/edi_webservice_receive_face_l10n_es_facturae_face_update.py b/l10n_es_facturae_face/components/edi_webservice_receive_face_l10n_es_facturae_face_update.py new file mode 100644 index 00000000000..3ea02adb70c --- /dev/null +++ b/l10n_es_facturae_face/components/edi_webservice_receive_face_l10n_es_facturae_face_update.py @@ -0,0 +1,40 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json + +from zeep import helpers + +from odoo import _ +from odoo.exceptions import UserError + +from odoo.addons.component.core import Component + + +class EdiWebServiceReceiveFaceL10nEsFacturaeFaceUpdate(Component): + _name = "edi.webservice.receive.face.l10n_es_facturae_face_update" + _usage = "input.receive" + _backend_type = "l10n_es_facturae" + _exchange_type = "l10n_es_facturae_face_update" + _inherit = ["edi.component.receive.mixin", "base.webservice.face"] + + def receive(self): + invoice = self.exchange_record.record + public_crt, private_key = self.env["l10n.es.aeat.certificate"].get_certificates( + invoice.company_id + ) + response = self.consult_invoice( + public_crt, + private_key, + self.exchange_record.parent_id.external_identifier, + ) + if response.resultado.codigo != "0": + raise UserError( + _("Connection with FACe returned error %(code)s - %(description)s") + % { + "code": response.resultado.codigo, + "description": response.resultado.descripcion, + } + ) + return json.dumps(helpers.serialize_object(response.factura)) diff --git a/l10n_es_facturae_face/components/webservice_face.py b/l10n_es_facturae_face/components/webservice_face.py new file mode 100644 index 00000000000..106acbc4ffd --- /dev/null +++ b/l10n_es_facturae_face/components/webservice_face.py @@ -0,0 +1,91 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import base64 +import logging + +from cryptography import x509 +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives import serialization + +from odoo.exceptions import UserError, ValidationError +from odoo.models import _ + +from odoo.addons.component.core import Component + +from ..models.wsse_signature import MemorySignature + +_logger = logging.getLogger(__name__) +try: + from zeep import Client +except (OSError, ImportError) as err: + _logger.info(err) + + +class WebServiceFace(Component): + _name = "base.webservice.face" + _usage = "face.protocol" + _backend_type = "l10n_es_facturae" + _inherit = "edi.component.mixin" + + def _get_client(self, public_crt, private_key): + with open(public_crt, "rb") as f: + cert = x509.load_pem_x509_certificate(f.read(), backend=default_backend()) + with open(private_key, "rb") as f: + key = serialization.load_pem_private_key( + f.read(), None, backend=default_backend() + ) + return Client( + wsdl=self.env["ir.config_parameter"].sudo().get_param("facturae.face.ws"), + wsse=MemorySignature( + cert, + key, + x509.load_pem_x509_certificate( + base64.b64decode( + self.env.ref("l10n_es_facturae_face.face_certificate").datas + ), + backend=default_backend(), + ), + ), + ) + + def send_webservice( + self, public_crt, private_key, file_data, file_name, email, anexos_list=False + ): + client = self._get_client(public_crt, private_key) + invoice_file = client.get_type("ns0:FacturaFile")( + base64.b64encode(file_data.encode("UTF-8")), + file_name, + "application/xml", + ) + anexos = client.get_type("ns0:ArrayOfAnexoFile")(anexos_list or []) + invoice_call = client.get_type("ns0:EnviarFacturaRequest")( + email, invoice_file, anexos + ) + response = client.service.enviarFactura(invoice_call) + if response.resultado.codigo != "0": + raise ValidationError(response.resultado.descripcion) + return response + + def consult_invoice(self, public_crt, private_key, invoice_number): + client = self._get_client(public_crt, private_key) + return client.service.consultarFactura(invoice_number) + + def consult_invoices(self, public_crt, private_key, invoices): + client = self._get_client(public_crt, private_key) + request = client.get_type("ns0:ConsultarListadoFacturaRequest")(invoices) + return client.service.consultarListadoFacturas(request) + + def cancel(self, public_crt, private_key, identifier, motive): + client = self._get_client(public_crt, private_key) + response = client.service.anularFactura(identifier, motive) + if response.resultado.codigo != "0": + raise UserError( + _("Connection with FACe returned error %(code)s - %(description)s") + % { + "code": response.resultado.codigo, + "description": response.resultado.descripcion, + } + ) + return response diff --git a/l10n_es_facturae_face/data/cron_data.xml b/l10n_es_facturae_face/data/cron_data.xml new file mode 100644 index 00000000000..ababe3a4c64 --- /dev/null +++ b/l10n_es_facturae_face/data/cron_data.xml @@ -0,0 +1,14 @@ + + + + FACe update Job + True + + 8 + days + code + -1 + + model._cron_face_update_method() + + diff --git a/l10n_es_facturae_face/data/edi.xml b/l10n_es_facturae_face/data/edi.xml new file mode 100644 index 00000000000..f273864b282 --- /dev/null +++ b/l10n_es_facturae_face/data/edi.xml @@ -0,0 +1,72 @@ + + + + Spanish Facturae Backend type + l10n_es_facturae + + + Spanish Facturae + l10n_es_facturae + + output + {record_name}--{dt} + xsig + + + + Default + + + [('state', '!=', 'draft'), ('partner_id', '!=', False), ('partner_id.l10n_es_facturae_sending_code', '=', "face"),('move_type', 'in', ['out_invoice', 'out_refund'])] + result = not record._has_exchange_record(exchange_type) + + + FACe + + + + + Update Facturae FACe + l10n_es_facturae_face_update + + + input + {record_name}--{dt} + json + + + Default + + + [('state', '!=', 'draft'), ('partner_id.l10n_es_facturae_sending_code', '=', "face")] + + result = record._has_exchange_record(record.env.ref("l10n_es_facturae_face.facturae_exchange_type"), record.env.ref("l10n_es_facturae_face.face_backend")) + + + Cancel Facturae FACe + l10n_es_facturae_face_cancel + + + output + {record_name}--{dt} + txt + + + Facturae output + + + l10n_es_facturae.facturae_file + xsig + report + + result = {"res_ids": record.ids} + + diff --git a/l10n_es_facturae_face/data/face_data.xml b/l10n_es_facturae_face/data/face_data.xml new file mode 100644 index 00000000000..d2b9ef30344 --- /dev/null +++ b/l10n_es_facturae_face/data/face_data.xml @@ -0,0 +1,51 @@ + + + + face_certificate.crt + LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUYvVENDQk9XZ0F3SUJBZ0lRVWo1b2Z5N1RZ +WGhXc0tCWlZ6Nmx4REFOQmdrcWhraUc5dzBCQVFzRkFEQkgKTVFzd0NRWURWUVFHRXdKRlV6RVJN +QThHQTFVRUNnd0lSazVOVkMxU1EwMHhKVEFqQmdOVkJBc01IRUZESUVOdgpiWEJ2Ym1WdWRHVnpJ +RWx1Wm05eWJjT2hkR2xqYjNNd0hoY05NVFl3TWpBeU1USXlOakF4V2hjTk1Ua3dNakF5Ck1USXlO +VFU1V2pDQjJERUxNQWtHQTFVRUJoTUNSVk14RHpBTkJnTlZCQWNNQmsxQlJGSkpSREU4TURvR0Ex +VUUKQ2d3elRVbE9TVk5VUlZKSlR5QkVSU0JJUVVOSlJVNUVRU0JaSUVGRVRVbE9TVk5VVWtGRFNV +OU9SVk1nVU1PYQpRa3hKUTBGVE1Vc3dTUVlEVlFRTERFSkVTVkpGUTBOSnc1Tk9JRVJGSUZSRlEw +NVBURTlIdzQxQlV5QkVSU0JNClFTQkpUa1pQVWsxQlEwbkRrMDRnV1NCTVFWTWdRMDlOVlU1SlEw +RkRTVTlPUlZNeEVqQVFCZ05WQkFVVENWTXkKT0RNek1EQXlSVEVaTUJjR0ExVUVBd3dRUkZSSlF5 +QkJSMFVnVUZKVlJVSkJVekNDQVNJd0RRWUpLb1pJaHZjTgpBUUVCQlFBRGdnRVBBRENDQVFvQ2dn +RUJBTEJjb3V5NXdrMVAxTHdxMzhiK21WYlpmb3Fza1BCZXBhd2llSGFyClExTnJrSkpWK2hJWU9u +Z0dYLzREZHBvVUtyL2V6QXFyTml1MG1IMVd4UEkrZVJMc2UxbG9VYmp3UVRneG5KSTkKUVAwdjc5 +TDZnMFVxTHlGY3d5eTcvZEl4VmtKVUlxN3FQSFhianZsZ3U1ZkN3NnVCOGgwRVEySmxycEtmcXRk +awpoK2lwRG1VZmluYWdlTTExc01YRWViUytZeE8waWlxSzBXZ0hQRzI3ZFN6ZDBUZm8yU0tRL1hI +c2d1VHRySW9WCjRra3RHaGtiN0lFcE84K0c4UXpIZDM0N0hpUUF5L01ydXplTEFKamFCaGNZemtD +bU1GdzV4V2M3azZQQjBTODIKaGVGQjZSTis0UkdZUDE0OVZJTkdTUXJTMFdxSVhyWEpDSExRYjVj +N0hCZU5wbTBDQXdFQUFhT0NBbEV3Z2dKTgpNQWtHQTFVZEV3UUNNQUF3Z1lFR0NDc0dBUVVGQndF +QkJIVXdjekE3QmdnckJnRUZCUWN3QVlZdmFIUjBjRG92CkwyOWpjM0JqYjIxd0xtTmxjblF1Wm01 +dGRDNWxjeTl2WTNOd0wwOWpjM0JTWlhOd2IyNWtaWEl3TkFZSUt3WUIKQlFVSE1BS0dLR2gwZEhB +Nkx5OTNkM2N1WTJWeWRDNW1ibTEwTG1WekwyTmxjblJ6TDBGRFEwOU5VQzVqY25RdwpSQVlEVlIw +Z0JEMHdPekE1QmdvckJnRUVBYXhtQXdrQ01Dc3dLUVlJS3dZQkJRVUhBZ0VXSFdoMGRIQTZMeTkz +CmQzY3VZMlZ5ZEM1bWJtMTBMbVZ6TDJSd1kzTXZNQzRHQTFVZEVRUW5NQ1drSXpBaE1SOHdIUVlK +S3dZQkJBR3MKWmdFSURCQkVWRWxESUVGSFJTQlFVbFZGUWtGVE1CTUdBMVVkSlFRTU1Bb0dDQ3NH +QVFVRkJ3TUNNQTRHQTFVZApEd0VCL3dRRUF3SUVzREFkQmdOVkhRNEVGZ1FVbVVQYUNLUzFHWFVM +UnY3VFlHRk1HNkJ4bWNRd0h3WURWUjBqCkJCZ3dGb0FVR2ZoWUx4VFdwc3liQkpnSURVelhxd0Nu +ZzJVd2dlQUdBMVVkSHdTQjJEQ0IxVENCMHFDQno2Q0IKeklhQm5teGtZWEE2THk5c1pHRndZMjl0 +Y0M1alpYSjBMbVp1YlhRdVpYTXZRMDQ5UTFKTU1TeFBWVDFCUXlVeQpNRU52YlhCdmJtVnVkR1Z6 +SlRJd1NXNW1iM0p0WVhScFkyOXpMRTg5Ums1TlZDMVNRMDBzUXoxRlV6OWpaWEowCmFXWnBZMkYw +WlZKbGRtOWpZWFJwYjI1TWFYTjBPMkpwYm1GeWVUOWlZWE5sUDI5aWFtVmpkR05zWVhOelBXTlMK +VEVScGMzUnlhV0oxZEdsdmJsQnZhVzUwaGlsb2RIUndPaTh2ZDNkM0xtTmxjblF1Wm01dGRDNWxj +eTlqY214egpZMjl0Y0M5RFVrd3hMbU55YkRBTkJna3Foa2lHOXcwQkFRc0ZBQU9DQVFFQVRsWjNE +UEZ6MWdRMzJZT1lJSUx6CmY5OWt1azJ3RllVTGcrWGFEcWlzL3kvUzZicGhLRjN4YnR5eHNJWCts +eDB6STE3ZHlEVEtBKzZzV05IaWl1SDQKWWpYa3FieGJJOEVZSGZlUnpiUkszUzRHajF5YXRHVnRo +c0NLNndEcmxyOFJyajhRZ250RkFNKy9rZnlzR0psSApFaUZzZ1ROMmlYZk9zam1YTk5LMUx3U2JR +M0dDd1BhTFlLWm9uTnNFajhQL1M1cjkxSUNlamZHbFZacDFBRVh5ClAzakp6aWJyMFNLeHdFdDMy +ci8rWmpUbVFnckx1QW1HcmdjVnNqQUFtMkNwN3VzSllhUy9TeVBGajFRRFVsWm8KVk91bzRkZmdG +VVpMQ1ZCZk1VQlk3M1dOYXpWQW9qcVpoRzlkOHRBZ2cyYzY0bnVzdU1EWSsyNU1MVUtGenNiegpG +Zz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KCg== + + + + facturae.face.ws + https://webservice.face.gob.es/facturasspp2?wsdl + + diff --git a/l10n_es_facturae_face/i18n/ca.po b/l10n_es_facturae_face/i18n/ca.po new file mode 100644 index 00000000000..c8e72b8f6ac --- /dev/null +++ b/l10n_es_facturae_face/i18n/ca.po @@ -0,0 +1,304 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_facturae_face +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-03 13:35+0000\n" +"Last-Translator: jabelchi \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2400 +msgid "Accepted" +msgstr "Acceptat" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "Cancel" +msgstr "Cancel·lar" + +#. module: l10n_es_facturae_face +#: model:ir.actions.act_window,name:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_act_window +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.view_move_form +msgid "Cancel FACe" +msgstr "Cancel·lar FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_edi_l10n_es_facturae_face_cancel +msgid "Cancel a FACe Exchange Record" +msgstr "Cancel·lar un registre d'intercanvi FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4300 +msgid "Cancellation accepted" +msgstr "Cancel·lació acceptada" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-3100 +msgid "Cancellation approved" +msgstr "Cancel·lació aprovada" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4400 +msgid "Cancellation rejected" +msgstr "Cancel·lació rebutjada" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4200 +msgid "Cancellation requested" +msgstr "Cancel·lació sol·licitada" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_res_company +msgid "Companies" +msgstr "Companyies" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/edi_exchange_record.py:0 +#, python-format +msgid "Company %s cannot be processed" +msgstr "La companyia %s no pot processar-se" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/components/edi_webservice_receive_face_l10n_es_facturae_face_update.py:0 +#: code:addons/l10n_es_facturae_face/components/webservice_face.py:0 +#, python-format +msgid "Connection with FACe returned error %(code)s - %(description)s" +msgstr "La connexió amb FACe ha retornat l'error %(code)s - %(description)s" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_res_partner +msgid "Contact" +msgstr "Contacte" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Country must be defined in order to send to FACe" +msgstr "Cal definir el país per tal d'enviar a FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__create_uid +msgid "Created by" +msgstr "Creat per" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__create_date +msgid "Created on" +msgstr "Creat el" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__display_name +msgid "Display Name" +msgstr "Nom a mostrar" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_edi_exchange_record +msgid "EDI exchange Record" +msgstr "Registre d'intercanvi EDI" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "Edi L10n Es Facturae FACe Cancel" +msgstr "Cancela Edi L10n Es Facturae FACe" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/components/account_move_l10n_es_facturae_face_listener.py:0 +#, python-format +msgid "Exchange record cannot be found for FACe" +msgstr "FACe no pot trobar el registre d'intercanvi" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__res_partner__l10n_es_facturae_sending_code__face +msgid "FACe" +msgstr "FACe" + +#. module: l10n_es_facturae_face +#: model:ir.actions.server,name:l10n_es_facturae_face.update_face_job_ir_actions_server +#: model:ir.cron,cron_name:l10n_es_facturae_face.update_face_job +msgid "FACe update Job" +msgstr "Actualitzar tasca FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_company__face_email +msgid "Face Email" +msgstr "Email FACe" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_exchange_record_view_form +msgid "Facturae" +msgstr "Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_cancellation_motive +msgid "Facturae Cancellation motive" +msgstr "Motiu de cancel·lació Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_cancellation_status +msgid "Facturae Cancellation state" +msgstr "Estat de cancel·lació Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_status +msgid "Facturae State" +msgstr "Estat facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_bank_statement_line__l10n_es_facturae_cancellation_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_move__l10n_es_facturae_cancellation_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_payment__l10n_es_facturae_cancellation_status +msgid "Facturae cancellation status" +msgstr "Estat de cancel·lació facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_motive +msgid "Facturae description" +msgstr "Descripció Facturae" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Facturae must be selected in order to send to FACe" +msgstr "Cal seleccionar Facturae per tal d'enviar a FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_bank_statement_line__l10n_es_facturae_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_move__l10n_es_facturae_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_payment__l10n_es_facturae_status +msgid "Facturae status" +msgstr "Estat Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__id +msgid "ID" +msgstr "ID" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_company.py:0 +#, python-format +msgid "Invalid facturae email" +msgstr "Email Facturae no vàlid" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_account_move +msgid "Journal Entry" +msgstr "Apunt comptable" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel____last_update +msgid "Last Modified on" +msgstr "Darrera modificació el" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__write_uid +msgid "Last Updated by" +msgstr "Darrera actualització per" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__write_date +msgid "Last Updated on" +msgstr "Darrera actualització el" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__motive +msgid "Motive" +msgstr "Motiu" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__move_id +msgid "Move" +msgstr "Moviment" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4100 +msgid "Not requested" +msgstr "No sol·licitat" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "OK" +msgstr "OK" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/account_move.py:0 +#, python-format +msgid "Organo Gestor not provided" +msgstr "No s'ha informat organ gestor" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2500 +msgid "Paid" +msgstr "Pagat" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-1300 +msgid "Registered on RCF" +msgstr "Enregistrat a RCF" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-1200 +msgid "Registered on REC" +msgstr "Enregistrat a REC" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2600 +msgid "Rejected" +msgstr "Rebutjat" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_partner__l10n_es_facturae_sending_code +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_users__l10n_es_facturae_sending_code +msgid "Sending method" +msgstr "Mètode de tramesa" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "State must be defined in Spain in order to send to FACe" +msgstr "Cal definir la província d'Espanya per a enviar a FACe" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Vat must be defined in order to send to FACe" +msgstr "Cal definir el NIF per a enviar per FACe" + +#~ msgid "Protocol" +#~ msgstr "Protocol" + +#~ msgid "WebService Backend" +#~ msgstr "WebService Backend" + +#~ msgid "Edi L10n Es Facturae Face Cancel" +#~ msgstr "Cancelar l10n es Facturae FACe" + +#~ msgid "Payed" +#~ msgstr "Pagat" + +#~ msgid "Config Settings" +#~ msgstr "Ajustos de configuració" + +#~ msgid "FACe Configuration" +#~ msgstr "Configuració FACe" + +#~ msgid "FACe server location" +#~ msgstr "Ubicació servidor FACe" diff --git a/l10n_es_facturae_face/i18n/es.po b/l10n_es_facturae_face/i18n/es.po new file mode 100644 index 00000000000..40b8fa7fbdf --- /dev/null +++ b/l10n_es_facturae_face/i18n/es.po @@ -0,0 +1,286 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_facturae_face +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-07-06 09:06+0000\n" +"PO-Revision-Date: 2023-07-05 19:08+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2400 +msgid "Accepted" +msgstr "Aceptado" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "Cancel" +msgstr "cancelar" + +#. module: l10n_es_facturae_face +#: model:ir.actions.act_window,name:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_act_window +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.view_move_form +msgid "Cancel FACe" +msgstr "Cancelar FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_edi_l10n_es_facturae_face_cancel +msgid "Cancel a FACe Exchange Record" +msgstr "Cancelar un registro de intercambio FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4300 +msgid "Cancellation accepted" +msgstr "Cancelación aceptada" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-3100 +msgid "Cancellation approved" +msgstr "Cancelación aprobada" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4400 +msgid "Cancellation rejected" +msgstr "Cancelación rechazada" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4200 +msgid "Cancellation requested" +msgstr "Cancelación solicitada" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_res_company +msgid "Companies" +msgstr "Compañías" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/edi_exchange_record.py:0 +#, python-format +msgid "Company %s cannot be processed" +msgstr "La compañía %s no puede procesarse" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/components/edi_webservice_receive_face_l10n_es_facturae_face_update.py:0 +#: code:addons/l10n_es_facturae_face/components/webservice_face.py:0 +#, python-format +msgid "Connection with FACe returned error %(code)s - %(description)s" +msgstr "La conexión con FACe devolvió error %(code)s-%(description)s" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Country must be defined in order to send to FACe" +msgstr "Se debe definir el país para poder enviar por FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__create_uid +msgid "Created by" +msgstr "creado por" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__create_date +msgid "Created on" +msgstr "creado el" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_edi_exchange_record +msgid "EDI exchange Record" +msgstr "Registro de intercambio EDI" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "Edi L10n Es Facturae FACe Cancel" +msgstr "Edi L10n Es Facturae FACe Cancelar" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/components/account_move_l10n_es_facturae_face_listener.py:0 +#, python-format +msgid "Exchange record cannot be found for FACe" +msgstr "No se encuentra el registro de intercambio para FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__res_partner__l10n_es_facturae_sending_code__face +msgid "FACe" +msgstr "FACe" + +#. module: l10n_es_facturae_face +#: model:ir.actions.server,name:l10n_es_facturae_face.update_face_job_ir_actions_server +#: model:ir.cron,cron_name:l10n_es_facturae_face.update_face_job +msgid "FACe update Job" +msgstr "Actualizar estados FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_company__face_email +msgid "Face Email" +msgstr "Email FACe" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_exchange_record_view_form +msgid "Facturae" +msgstr "Facturae(factura electrónica)" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_cancellation_motive +msgid "Facturae Cancellation motive" +msgstr "Motivo de anulación Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_cancellation_status +msgid "Facturae Cancellation state" +msgstr "Estado de anulación Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_status +msgid "Facturae State" +msgstr "estado de Facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_bank_statement_line__l10n_es_facturae_cancellation_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_move__l10n_es_facturae_cancellation_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_payment__l10n_es_facturae_cancellation_status +msgid "Facturae cancellation status" +msgstr "Estado de cancelación de la facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_motive +msgid "Facturae description" +msgstr "descripción de la facturae" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Facturae must be selected in order to send to FACe" +msgstr "Se debe seleccionar el campo facturae para poder enviar por FACe" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_bank_statement_line__l10n_es_facturae_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_move__l10n_es_facturae_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_payment__l10n_es_facturae_status +msgid "Facturae status" +msgstr "estado de la facturae" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__id +msgid "ID" +msgstr "ID(identificador)" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_company.py:0 +#, python-format +msgid "Invalid facturae email" +msgstr "Email de Facturae inválido" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_account_move +msgid "Journal Entry" +msgstr "Asiento contable" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__write_uid +msgid "Last Updated by" +msgstr "actualizado por última vez por" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__write_date +msgid "Last Updated on" +msgstr "actualizado por última vez el" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__motive +msgid "Motive" +msgstr "Motivo" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__move_id +msgid "Move" +msgstr "Mover" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4100 +msgid "Not requested" +msgstr "No solicitado" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "OK" +msgstr "Aceptar" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/account_move.py:0 +#, python-format +msgid "Organo Gestor not provided" +msgstr "El Organo Gestor es obligatorio" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2500 +msgid "Paid" +msgstr "Pagado" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-1300 +msgid "Registered on RCF" +msgstr "Registrado en RCF" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-1200 +msgid "Registered on REC" +msgstr "Registrado en REC" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2600 +msgid "Rejected" +msgstr "Rechazado" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_partner__l10n_es_facturae_sending_code +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_users__l10n_es_facturae_sending_code +msgid "Sending method" +msgstr "Método de envío" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "State must be defined in Spain in order to send to FACe" +msgstr "" +"La provincia debe estar definido si el país es España para poder enviar por " +"FACe" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Vat must be defined in order to send to FACe" +msgstr "El identificador fiscal debe estar definido para poder enviar por FACe" diff --git a/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot b/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot new file mode 100644 index 00000000000..4d37028eab5 --- /dev/null +++ b/l10n_es_facturae_face/i18n/l10n_es_facturae_face.pot @@ -0,0 +1,280 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_es_facturae_face +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2400 +msgid "Accepted" +msgstr "" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "Cancel" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.actions.act_window,name:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_act_window +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.view_move_form +msgid "Cancel FACe" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_edi_l10n_es_facturae_face_cancel +msgid "Cancel a FACe Exchange Record" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4300 +msgid "Cancellation accepted" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-3100 +msgid "Cancellation approved" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4400 +msgid "Cancellation rejected" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4200 +msgid "Cancellation requested" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_res_company +msgid "Companies" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/edi_exchange_record.py:0 +#, python-format +msgid "Company %s cannot be processed" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/components/edi_webservice_receive_face_l10n_es_facturae_face_update.py:0 +#: code:addons/l10n_es_facturae_face/components/webservice_face.py:0 +#, python-format +msgid "Connection with FACe returned error %(code)s - %(description)s" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Country must be defined in order to send to FACe" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__create_uid +msgid "Created by" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__create_date +msgid "Created on" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__display_name +msgid "Display Name" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_edi_exchange_record +msgid "EDI exchange Record" +msgstr "" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "Edi L10n Es Facturae FACe Cancel" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/components/account_move_l10n_es_facturae_face_listener.py:0 +#, python-format +msgid "Exchange record cannot be found for FACe" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__res_partner__l10n_es_facturae_sending_code__face +msgid "FACe" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.actions.server,name:l10n_es_facturae_face.update_face_job_ir_actions_server +#: model:ir.cron,cron_name:l10n_es_facturae_face.update_face_job +msgid "FACe update Job" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_company__face_email +msgid "Face Email" +msgstr "" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_exchange_record_view_form +msgid "Facturae" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_cancellation_motive +msgid "Facturae Cancellation motive" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_cancellation_status +msgid "Facturae Cancellation state" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_status +msgid "Facturae State" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_bank_statement_line__l10n_es_facturae_cancellation_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_move__l10n_es_facturae_cancellation_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_payment__l10n_es_facturae_cancellation_status +msgid "Facturae cancellation status" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_exchange_record__l10n_es_facturae_motive +msgid "Facturae description" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Facturae must be selected in order to send to FACe" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_bank_statement_line__l10n_es_facturae_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_move__l10n_es_facturae_status +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_account_payment__l10n_es_facturae_status +msgid "Facturae status" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__id +msgid "ID" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_company.py:0 +#, python-format +msgid "Invalid facturae email" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model,name:l10n_es_facturae_face.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel____last_update +msgid "Last Modified on" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__write_date +msgid "Last Updated on" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__motive +msgid "Motive" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_edi_l10n_es_facturae_face_cancel__move_id +msgid "Move" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_cancellation_status__face-4100 +msgid "Not requested" +msgstr "" + +#. module: l10n_es_facturae_face +#: model_terms:ir.ui.view,arch_db:l10n_es_facturae_face.edi_l10n_es_facturae_face_cancel_form_view +msgid "OK" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/account_move.py:0 +#, python-format +msgid "Organo Gestor not provided" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2500 +msgid "Paid" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-1300 +msgid "Registered on RCF" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-1200 +msgid "Registered on REC" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields.selection,name:l10n_es_facturae_face.selection__account_move__l10n_es_facturae_status__face-2600 +msgid "Rejected" +msgstr "" + +#. module: l10n_es_facturae_face +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_partner__l10n_es_facturae_sending_code +#: model:ir.model.fields,field_description:l10n_es_facturae_face.field_res_users__l10n_es_facturae_sending_code +msgid "Sending method" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "State must be defined in Spain in order to send to FACe" +msgstr "" + +#. module: l10n_es_facturae_face +#. odoo-python +#: code:addons/l10n_es_facturae_face/models/res_partner.py:0 +#, python-format +msgid "Vat must be defined in order to send to FACe" +msgstr "" diff --git a/l10n_es_facturae_face/models/__init__.py b/l10n_es_facturae_face/models/__init__.py new file mode 100644 index 00000000000..7d6656a5412 --- /dev/null +++ b/l10n_es_facturae_face/models/__init__.py @@ -0,0 +1,6 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import res_partner +from . import res_company +from . import account_move +from . import edi_exchange_record diff --git a/l10n_es_facturae_face/models/account_move.py b/l10n_es_facturae_face/models/account_move.py new file mode 100644 index 00000000000..9e64ea5fecb --- /dev/null +++ b/l10n_es_facturae_face/models/account_move.py @@ -0,0 +1,92 @@ +# (Copyright) 2020 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class AccountMove(models.Model): + _inherit = "account.move" + + l10n_es_facturae_status = fields.Selection( + selection=[ + ("face-1200", "Registered on REC"), + ("face-1300", "Registered on RCF"), + ("face-2400", "Accepted"), + ("face-2500", "Paid"), + ("face-2600", "Rejected"), + ("face-3100", "Cancellation approved"), + ], + tracking=True, + readonly=True, + string="Facturae status", + copy=False, + ) + l10n_es_facturae_cancellation_status = fields.Selection( + selection=[ + ("face-4100", "Not requested"), + ("face-4200", "Cancellation requested"), + ("face-4300", "Cancellation accepted"), + ("face-4400", "Cancellation rejected"), + ], + tracking=True, + readonly=True, + string="Facturae cancellation status", + copy=False, + ) + + def _get_edi_missing_records(self): + result = super()._get_edi_missing_records() + if result: + return result + if self.move_type not in ["out_invoice", "out_refund"]: + return False + partner = self.partner_id + if not partner.facturae or not partner.l10n_es_facturae_sending_code: + return False + return not self._has_exchange_record( + self.env.ref("l10n_es_facturae_face.facturae_exchange_type"), + self.env.ref("l10n_es_facturae_face.backend_facturae"), + ) + + @api.model + def _edi_missing_records_fields(self): + result = super()._edi_missing_records_fields() + return result + [ + "l10n_es_facturae_status", + "partner_id.l10n_es_facturae_sending_code", + ] + + def _has_exchange_record_domain( + self, exchange_type, backend=False, extra_domain=False + ): + domain = super()._has_exchange_record_domain( + exchange_type, backend=backend, extra_domain=extra_domain + ) + if exchange_type == self.env.ref( + "l10n_es_facturae_face.facturae_exchange_type" + ): + domain += [ + "|", + ("l10n_es_facturae_status", "=", False), + ( + "l10n_es_facturae_status", + "not in", + self._get_l10n_es_facturae_excluded_status(), + ), + ] + return domain + + @api.model + def _get_l10n_es_facturae_excluded_status(self): + return [ + "face-2600", + "face-3100", + ] + + def validate_facturae_fields(self): + super().validate_facturae_fields() + if not self.partner_id.organo_gestor: + raise ValidationError(_("Organo Gestor not provided")) + return diff --git a/l10n_es_facturae_face/models/edi_exchange_record.py b/l10n_es_facturae_face/models/edi_exchange_record.py new file mode 100644 index 00000000000..11e5b943563 --- /dev/null +++ b/l10n_es_facturae_face/models/edi_exchange_record.py @@ -0,0 +1,116 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json +import logging + +from zeep import helpers + +from odoo import _, fields, models + +_logger = logging.getLogger(__name__) + + +class EdiExchangeRecord(models.Model): + _inherit = "edi.exchange.record" + + l10n_es_facturae_status = fields.Selection( + selection=lambda r: r.env["account.move"] + ._fields["l10n_es_facturae_status"] + .selection, + readonly=True, + string="Facturae State", + ) + l10n_es_facturae_cancellation_status = fields.Selection( + selection=lambda r: r.env["account.move"] + ._fields["l10n_es_facturae_cancellation_status"] + .selection, + readonly=True, + string="Facturae Cancellation state", + ) + l10n_es_facturae_motive = fields.Text( + string="Facturae description", + readonly=True, + ) + l10n_es_facturae_cancellation_motive = fields.Text( + readonly=True, string="Facturae Cancellation motive" + ) + + def _cron_face_update_method(self, company_domain=False): + if not company_domain: + company_domain = [] + face = self.env.ref("l10n_es_facturae_face.face_backend") + integrations = self.search( + [ + ("backend_id", "=", face.id), + ( + "edi_exchange_state", + "in", + ["output_sent_and_processed", "output_sent"], + ), + ("model", "=", "account.move"), + "|", + ("l10n_es_facturae_status", "=", False), + ( + "l10n_es_facturae_status", + "in", + ["face-1200", "face-1300", "face-2400"], + ), + ] + ) + if not integrations: + return + for company in self.env["res.company"].search(company_domain): + company_integrations = integrations.filtered( + lambda r, company=company: r.record.company_id == company + ) + if not company_integrations: + continue + exchange_dict = {} + exchanges = [] + for integration in company_integrations: + exchanges.append(integration.external_identifier) + exchange_dict[integration.external_identifier] = integration + public_crt, private_key = self.env[ + "l10n.es.aeat.certificate" + ].get_certificates(company) + response = face._find_component( + face._name, + ["face.protocol"], + work_ctx={"exchange_record": self.env["edi.exchange.record"]}, + ).consult_invoices( + public_crt, + private_key, + exchanges, + ) + if response.resultado.codigo != "0": + _logger.info(_("Company %s cannot be processed") % company.display_name) + continue + for invoice in response.facturas.consultarListadoFactura: + exchange_record = exchange_dict[invoice.factura.numeroRegistro] + if invoice.codigo != "0": + # Probably processed from another system + continue + process_code = "face-" + invoice.factura.tramitacion.codigo + revocation_code = "face-" + invoice.factura.anulacion.codigo + if ( + exchange_record.l10n_es_facturae_status == process_code + and exchange_record.l10n_es_facturae_cancellation_status + == revocation_code + ): + continue + update_record = face.create_record( + "l10n_es_facturae_face_update", + { + "edi_exchange_state": "input_received", + "model": exchange_record.model, + "res_id": exchange_record.res_id, + "parent_id": exchange_record.id, + }, + ) + update_record._set_file_content( + json.dumps(helpers.serialize_object(invoice.factura)) + ) + face.with_context(_edi_send_break_on_error=True).exchange_process( + update_record + ) diff --git a/l10n_es_facturae_face/models/res_company.py b/l10n_es_facturae_face/models/res_company.py new file mode 100644 index 00000000000..193703faf31 --- /dev/null +++ b/l10n_es_facturae_face/models/res_company.py @@ -0,0 +1,22 @@ +# © 2017 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import re + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class ResCompany(models.Model): + _inherit = "res.company" + + face_email = fields.Char() + + @api.constrains("face_email") + def check_face_email(self): + for record in self: + if record.face_email and not re.match( + "(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$)", + record.face_email, + ): + raise ValidationError(_("Invalid facturae email")) diff --git a/l10n_es_facturae_face/models/res_partner.py b/l10n_es_facturae_face/models/res_partner.py new file mode 100644 index 00000000000..212d5f3646c --- /dev/null +++ b/l10n_es_facturae_face/models/res_partner.py @@ -0,0 +1,47 @@ +# © 2017 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +from odoo import _, api, exceptions, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + l10n_es_facturae_sending_code = fields.Selection( + [("face", "FACe")], string="Sending method" + ) + # TODO: Replace this by a boolean on 15.0. We are keeping this on 13 and 14 because + # migration might be problematic + + @api.constrains( + "facturae", + "vat", + "country_id", + "state_id", + "l10n_es_facturae_sending_code", + ) + def _constrain_l10n_es_facturae_sending_code_face(self): + for record in self: + if ( + not record.l10n_es_facturae_sending_code + or record.l10n_es_facturae_sending_code != "face" + ): + continue + if not record.facturae: + raise exceptions.ValidationError( + _("Facturae must be selected in order to send to FACe") + ) + if not record.vat: + raise exceptions.ValidationError( + _("Vat must be defined in order to send to FACe") + ) + if not record.country_id: + raise exceptions.ValidationError( + _("Country must be defined in order to send to FACe") + ) + if record.country_id.code_alpha3 == "ESP": + if not record.state_id: + raise exceptions.ValidationError( + _("State must be defined in Spain in order to send to FACe") + ) diff --git a/l10n_es_facturae_face/models/wsse_signature.py b/l10n_es_facturae_face/models/wsse_signature.py new file mode 100644 index 00000000000..e2a56e3ef52 --- /dev/null +++ b/l10n_es_facturae_face/models/wsse_signature.py @@ -0,0 +1,198 @@ +# © 2017 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +"""Functions for WS-Security (WSSE) signature creation and verification. + +Heavily based on test examples in https://github.com/mehcode/python-xmlsec as +well as the xmlsec documentation at https://www.aleksey.com/xmlsec/. + +Reading the xmldsig, xmlenc, and ws-security standards documents, though +admittedly painful, will likely assist in understanding the code in this +module. + +""" +import base64 +import logging +from datetime import datetime, timedelta + +from lxml import etree +from lxml.etree import QName + +try: + import xmlsig + from cryptography import x509 + from cryptography.hazmat.backends import default_backend + from cryptography.hazmat.primitives import serialization + from zeep import ns + from zeep.exceptions import SignatureVerificationFailed + from zeep.utils import detect_soap_env + from zeep.wsse.utils import ensure_id, get_security_header +except (OSError, ImportError) as err: + logging.info(err) + +# SOAP envelope +SOAP_NS = "http://schemas.xmlsoap.org/soap/envelope/" + + +def _read_file(f_name): + with open(f_name, "rb") as f: + return f.read() + + +class MemorySignature: + """Sign given SOAP envelope with WSSE sig using given key and cert.""" + + def __init__(self, public_cert, private_key, cert_data, password=None): + self.public_cert = public_cert + self.private_key = private_key + self.cert_data = cert_data + self.password = password + + def apply(self, envelope, headers): + signed = sign_envelope( + envelope, self.public_cert, self.private_key, self.cert_data, self.password + ) + return signed, headers + + def verify(self, envelope): + verify_envelope(envelope, self.cert_data) + return envelope + + +class Signature(MemorySignature): + """Sign given SOAP envelope with WSSE sig using given key file and + cert file.""" + + def __init__(self, key_file, certfile, password=None): + super().__init__(_read_file(key_file), _read_file(certfile), password) + + +def sign_envelope(envelope, public_cert, private_key, certfile, password): + reference_id = "Reference" + security = get_security_header(envelope) + security.set(QName(ns.SOAP_ENV_11, "mustUnderstand"), "1") + x509type = ( + "http://docs.oasis-open.org/wss/2004/01/" + "oasis-200401-wss-x509-token-profile-1.0#X509v3" + ) + encoding_type = ( + "http://docs.oasis-open.org/wss/2004/01/" + "oasis-200401-wss-soap-message-security-1.0#Base64Binary" + ) + binary_token = etree.SubElement( + security, + QName(ns.WSSE, "BinarySecurityToken"), + attrib={ + QName(ns.WSU, "Id"): reference_id, + "ValueType": x509type, + "EncodingType": encoding_type, + }, + ) + binary_token.text = base64.b64encode( + public_cert.public_bytes(encoding=serialization.Encoding.DER) + ) + signature = xmlsig.template.create( + c14n_method=xmlsig.constants.TransformExclC14N, + sign_method=xmlsig.constants.TransformRsaSha1, + ns="ds", + ) + envelope.append(signature) + + # Add a KeyInfo node with X509Data child to the Signature. XMLSec will fill + # in this template with the actual certificate details when it signs. + key_info = xmlsig.template.ensure_key_info(signature) + sec_token_ref = etree.SubElement(key_info, QName(ns.WSSE, "SecurityTokenReference")) + etree.SubElement( + sec_token_ref, + QName(ns.WSSE, "Reference"), + attrib={"URI": "#" + reference_id, "ValueType": x509type}, + ) + # Insert the Signature node in the wsse:Security header. + + security.append(signature) + + # Perform the actual signing. + ctx = xmlsig.SignatureContext() + ctx.x509 = public_cert + ctx.public_key = public_cert.public_key() + ctx.private_key = private_key + + timestamp = etree.SubElement(security, QName(ns.WSU, "Timestamp")) + now = datetime.now() + etree.SubElement(timestamp, QName(ns.WSU, "Created")).text = now.strftime( + "%Y-%m-%dT%H:%M:%SZ" + ) + exp = now + timedelta(hours=1) + etree.SubElement(timestamp, QName(ns.WSU, "Expires")).text = exp.strftime( + "%Y-%m-%dT%H:%M:%SZ" + ) + + soap_env = detect_soap_env(envelope) + _sign_node(ctx, signature, envelope.find(QName(soap_env, "Body"))) + _sign_node(ctx, signature, security.find(QName(ns.WSU, "Timestamp"))) + + ctx.sign(signature) + return etree.fromstring(etree.tostring(envelope, method="c14n")) + + +def verify_envelope(envelope, cert): + """Verify WS-Security signature on given SOAP envelope with given cert. + + Expects a document like that found in the sample XML in the ``sign()`` + docstring. + + Raise SignatureVerificationFailed on failure, silent on success. + + """ + soap_env = detect_soap_env(envelope) + + header = envelope.find(QName(soap_env, "Header")) + if header is None: + raise SignatureVerificationFailed() + + security = header.find(QName(ns.WSSE, "Security")) + signature = security.find(QName(ns.DS, "Signature")) + key_text = security.find(QName(ns.WSSE, "BinarySecurityToken")).text + key = x509.load_der_x509_certificate( + base64.b64decode(key_text), backend=default_backend() + ) + ctx = xmlsig.SignatureContext() + ctx.public_key = key.public_key() + try: + ctx.verify(signature) + except Exception: + # Sadly xmlsec gives us no details about the reason for the failure, so + # we have nothing to pass on except that verification failed. + raise SignatureVerificationFailed() from None + + +def _sign_node(ctx, signature, target): + """Add sig for ``target`` in ``signature`` node, using ``ctx`` context. + + Doesn't actually perform the signing; ``ctx.sign(signature)`` should be + called later to do that. + + Adds a Reference node to the signature with URI attribute pointing to the + target node, and registers the target node's ID so XMLSec will be able to + find the target node by ID when it signs. + + """ + + # Ensure the target node has a wsu:Id attribute and get its value. + node_id = ensure_id(target) + + # Unlike HTML, XML doesn't have a single standardized Id. WSSE suggests the + # use of the wsu:Id attribute for this purpose, but XMLSec doesn't + # understand that natively. So for XMLSec to be able to find the referenced + # node by id, we have to tell xmlsec about it using the register_id method. + # ctx.register_id(target, "Id", ns.WSU) + + # Add reference to signature with URI attribute pointing to that ID. + ref = xmlsig.template.add_reference( + signature, xmlsig.constants.TransformSha1, uri="#" + node_id + ) + # This is an XML normalization transform which will be performed on the + # target node contents before signing. This ensures that changes to + # irrelevant whitespace, attribute ordering, etc won't invalidate the + # signature. + xmlsig.template.add_transform(ref, xmlsig.constants.TransformExclC14N) diff --git a/l10n_es_facturae_face/pyproject.toml b/l10n_es_facturae_face/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/l10n_es_facturae_face/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_es_facturae_face/readme/CONFIGURE.md b/l10n_es_facturae_face/readme/CONFIGURE.md new file mode 100644 index 00000000000..74de5811b8d --- /dev/null +++ b/l10n_es_facturae_face/readme/CONFIGURE.md @@ -0,0 +1,29 @@ +- Es necesario añadir el correo electrónico al que notificar los cambios + de estado en la empresa +- Se debe configurar el servidor de envío +- Por defecto se añado el servicio web de test: + +- Si queremos añadir el de producción, debemos cambiar el parámetro por + y modificar el + certificado en parámetros de sistema + +Para poder enviar correctamente, debemos subir el certificado al entorno +correspondiente, para ello, accederemos a +(Producción) o (Desarrollo). Allí, +accederemos a Integradores/Gestión de certificados y nos loguearemos con +Certificado Electrónico. Una vez dentro, debemos darnos de alta como +integrador creando una incidencia en la URL que nos aparecerá. El +siguiente +[documento](https://administracionelectronica.gob.es/PAe/FACE/altaintegrador) +tiene toda la información detallada. + +Cuando nos confirmen el alta, será necesario subir la parte pública de +nuestro certificado, un comando para exportarlo es: + +``` bash +openssl pkcs12 -in MI_CERTIFICADO.pfx -out MI_CERTIFICADO.crt -nokeys -clcerts +cat MI_CERTIFICADO.crt +``` + +Deberemos añadir toda la parte entre -----BEGIN CERTIFICATE----- y +-----END CERTIFICATE----- incluidos ambos. diff --git a/l10n_es_facturae_face/readme/CONTRIBUTORS.md b/l10n_es_facturae_face/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..64dca826b10 --- /dev/null +++ b/l10n_es_facturae_face/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Enric Tobella \<\> +- Eric Antones \<\> +- Manuel Regidor \<\> +- Valentín Vinagre \<\> diff --git a/l10n_es_facturae_face/readme/DESCRIPTION.md b/l10n_es_facturae_face/readme/DESCRIPTION.md new file mode 100644 index 00000000000..3187696b273 --- /dev/null +++ b/l10n_es_facturae_face/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +Este módulo permite la gestión del envío de la facturación electrónica +española a FACe. La gestión del envío se realiza mediante los +certificados con los que se firma. diff --git a/l10n_es_facturae_face/readme/USAGE.md b/l10n_es_facturae_face/readme/USAGE.md new file mode 100644 index 00000000000..cd21cb02bb7 --- /dev/null +++ b/l10n_es_facturae_face/readme/USAGE.md @@ -0,0 +1,41 @@ +## Configurar clientes + +- Accedemos a un cliente + - Le configuramos la opción de factura electrónica y rellenamos los + datos obligatorios + - Marcamos como método de envío FACe +- A partir de este momento, todas las facturas que validemos del cliente + se enviarán automáticamente a no ser que marquemos la opción de + Deshabilitar envío EDI + +## Envío de facturas + +- Cuando validemos una factura de un cliente configurado a enviar por + FACe se creará un registro de Envío EDI +- Mediante un job, se generarán los datos necesarios y, posteriormente, + se enviará como un registro EDI estándar +- Una vez se envíe, se alamacenará en la factura el resultado y el + número de registro +- Tras eso, podremos actualizar el estado de forma online presionando el + botón Actualizar Estado FACe +- Además, también podremos solicitar la anulación de la factura pulsando + 'Cancelar Envío' e introduciendo el motivo + +Es importante tener en cuenta que: + +- Un registro Enviado correctamente no puede ser Eliminado +- Sólo puede existir un envío Enviado correctamente (no cancelado) +- Se genera una tarea programada que actualiza los registros enviados + correctamente no pagados y no anulados +- En caso de que se anule la factura por parte del cliente, podremos + reenviarla de nuevo + +## Envío manual de facturas + +- Esto podría pasarnos con facturas antiguas en las que configuramos el + cliente tras emitir la factura o en las que hemos deshabilitado el + envío automático +- Accedemos a una factura validada del cliente no enviada y pulsamos el + botón 'Spanish Facturae'. En caso de salirnos una opción de elección, + deberemos seleccionara FACe +- Tras esto, funcionará de la misma forma que un envío estándar diff --git a/l10n_es_facturae_face/security/ir.model.access.csv b/l10n_es_facturae_face/security/ir.model.access.csv new file mode 100644 index 00000000000..dcf91bbdf99 --- /dev/null +++ b/l10n_es_facturae_face/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_edi_l10n_es_facturae_face_cancel,access_edi_l10n_es_facturae_face_cancel,model_edi_l10n_es_facturae_face_cancel,account.group_account_invoice,1,1,1,0 diff --git a/l10n_es_facturae_face/static/description/icon.png b/l10n_es_facturae_face/static/description/icon.png new file mode 100644 index 00000000000..5265804804d Binary files /dev/null and b/l10n_es_facturae_face/static/description/icon.png differ diff --git a/l10n_es_facturae_face/static/description/index.html b/l10n_es_facturae_face/static/description/index.html new file mode 100644 index 00000000000..c1df2260f6c --- /dev/null +++ b/l10n_es_facturae_face/static/description/index.html @@ -0,0 +1,517 @@ + + + + + +Envío de Facturae a FACe + + + +
+

Envío de Facturae a FACe

+ + +

Beta License: AGPL-3 OCA/l10n-spain Translate me on Weblate Try me on Runboat

+

Este módulo permite la gestión del envío de la facturación electrónica +española a FACe. La gestión del envío se realiza mediante los +certificados con los que se firma.

+

Table of contents

+ +
+

Configuration

+ +

Para poder enviar correctamente, debemos subir el certificado al entorno +correspondiente, para ello, accederemos a https://face.gob.es +(Producción) o https://se-face.redsara.es (Desarrollo). Allí, +accederemos a Integradores/Gestión de certificados y nos loguearemos con +Certificado Electrónico. Una vez dentro, debemos darnos de alta como +integrador creando una incidencia en la URL que nos aparecerá. El +siguiente +documento +tiene toda la información detallada.

+

Cuando nos confirmen el alta, será necesario subir la parte pública de +nuestro certificado, un comando para exportarlo es:

+
+openssl pkcs12 -in MI_CERTIFICADO.pfx -out MI_CERTIFICADO.crt -nokeys -clcerts
+cat MI_CERTIFICADO.crt
+
+

Deberemos añadir toda la parte entre —–BEGIN CERTIFICATE—– y +—–END CERTIFICATE—– incluidos ambos.

+
+
+

Usage

+
+

Configurar clientes

+
    +
  • Accedemos a un cliente
      +
    • Le configuramos la opción de factura electrónica y rellenamos los +datos obligatorios
    • +
    • Marcamos como método de envío FACe
    • +
    +
  • +
  • A partir de este momento, todas las facturas que validemos del +cliente se enviarán automáticamente a no ser que marquemos la opción +de Deshabilitar envío EDI
  • +
+
+
+

Envío de facturas

+
    +
  • Cuando validemos una factura de un cliente configurado a enviar por +FACe se creará un registro de Envío EDI
  • +
  • Mediante un job, se generarán los datos necesarios y, posteriormente, +se enviará como un registro EDI estándar
  • +
  • Una vez se envíe, se alamacenará en la factura el resultado y el +número de registro
  • +
  • Tras eso, podremos actualizar el estado de forma online presionando +el botón Actualizar Estado FACe
  • +
  • Además, también podremos solicitar la anulación de la factura +pulsando ‘Cancelar Envío’ e introduciendo el motivo
  • +
+

Es importante tener en cuenta que:

+
    +
  • Un registro Enviado correctamente no puede ser Eliminado
  • +
  • Sólo puede existir un envío Enviado correctamente (no cancelado)
  • +
  • Se genera una tarea programada que actualiza los registros enviados +correctamente no pagados y no anulados
  • +
  • En caso de que se anule la factura por parte del cliente, podremos +reenviarla de nuevo
  • +
+
+
+

Envío manual de facturas

+
    +
  • Esto podría pasarnos con facturas antiguas en las que configuramos el +cliente tras emitir la factura o en las que hemos deshabilitado el +envío automático
  • +
  • Accedemos a una factura validada del cliente no enviada y pulsamos el +botón ‘Spanish Facturae’. En caso de salirnos una opción de elección, +deberemos seleccionara FACe
  • +
  • Tras esto, funcionará de la misma forma que un envío estándar
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

etobella

+

This module is part of the OCA/l10n-spain project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_es_facturae_face/tests/__init__.py b/l10n_es_facturae_face/tests/__init__.py new file mode 100644 index 00000000000..1241c2f460e --- /dev/null +++ b/l10n_es_facturae_face/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_facturae_face diff --git a/l10n_es_facturae_face/tests/test_facturae_face.py b/l10n_es_facturae_face/tests/test_facturae_face.py new file mode 100644 index 00000000000..fde3031f3a8 --- /dev/null +++ b/l10n_es_facturae_face/tests/test_facturae_face.py @@ -0,0 +1,409 @@ +# © 2017 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import logging +from unittest import mock + +import requests + +from odoo import exceptions + +from odoo.addons.edi_oca.tests.common import EDIBackendCommonComponentRegistryTestCase +from odoo.addons.l10n_es_aeat.tests.test_l10n_es_aeat_certificate import ( + TestL10nEsAeatCertificateBase, +) + +_logger = logging.getLogger(__name__) +try: + from zeep import Client +except (OSError, ImportError) as err: + _logger.info(err) + + +class EDIBackendTestCase( + EDIBackendCommonComponentRegistryTestCase, TestL10nEsAeatCertificateBase +): + @classmethod + def setUpClass(cls): + cls._super_send = requests.Session.send + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + self = cls + + self._load_module_components(self, "component_event") + self._load_module_components(self, "edi_oca") + self._load_module_components(self, "edi_account_oca") + self._load_module_components(self, "l10n_es_facturae") + self._load_module_components(self, "l10n_es_facturae_face") + self.tax = self.env["account.tax"].create( + { + "name": "Test tax", + "amount_type": "percent", + "amount": 21, + "type_tax_use": "sale", + "facturae_code": "01", + } + ) + + self.state = self.env["res.country.state"].create( + { + "name": "Ciudad Real", + "code": "13", + "country_id": self.env.ref("base.es").id, + } + ) + self.partner = self.env["res.partner"].create( + { + "name": "Cliente de prueba", + "street": "C/ Ejemplo, 13", + "zip": "13700", + "city": "Tomelloso", + "state_id": self.state.id, + "country_id": self.env.ref("base.es").id, + "vat": "ES05680675C", + "facturae": True, + "attach_invoice_as_annex": False, + "organo_gestor": "U00000038", + "unidad_tramitadora": "U00000038", + "oficina_contable": "U00000038", + "l10n_es_facturae_sending_code": "face", + } + ) + main_company = self.env.ref("base.main_company") + main_company.vat = "ESA12345674" + main_company.partner_id.country_id = self.env.ref("base.uk") + self.env["res.currency.rate"].search( + [("currency_id", "=", main_company.currency_id.id)] + ).write({"company_id": False}) + bank_obj = self.env["res.partner.bank"] + self.bank = bank_obj.search( + [("acc_number", "=", "FR20 1242 1242 1242 1242 1242 124")], limit=1 + ) + if not self.bank: + self.bank = bank_obj.create( + { + "acc_number": "FR20 1242 1242 1242 1242 1242 124", + "partner_id": main_company.partner.id, + "bank_id": self.env["res.bank"] + .search([("bic", "=", "PSSTFRPPXXX")], limit=1) + .id, + } + ) + self.payment_method = self.env.ref("account.account_payment_method_manual_in") + payment_methods = self.env["account.payment.method"].search( + [("payment_type", "=", "inbound")] + ) + self.journal = self.env["account.journal"].create( + { + "name": "Test journal", + "code": "TEST", + "type": "bank", + "company_id": main_company.id, + "bank_account_id": self.bank.id, + "inbound_payment_method_line_ids": [ + (0, 0, {"payment_method_id": x.id}) for x in payment_methods + ], + } + ) + + self.sale_journal = self.env["account.journal"].create( + { + "name": "Sale journal", + "code": "SALE_TEST", + "type": "sale", + "company_id": main_company.id, + } + ) + self.payment_mode = self.env["account.payment.mode"].create( + { + "name": "Test payment mode", + "bank_account_link": "fixed", + "fixed_journal_id": self.journal.id, + "payment_method_id": self.payment_method.id, + "show_bank_account_from_journal": True, + "facturae_code": "01", + } + ) + + self.payment_mode_02 = self.env["account.payment.mode"].create( + { + "name": "Test payment mode 02", + "bank_account_link": "fixed", + "fixed_journal_id": self.journal.id, + "payment_method_id": self.payment_method.id, + "show_bank_account_from_journal": True, + "facturae_code": "02", + } + ) + + self.account = self.env["account.account"].create( + { + "company_id": main_company.id, + "name": "Facturae Product account", + "code": "facturaeproduct", + "account_type": "income", + } + ) + self.move = self.env["account.move"].create( + { + "partner_id": self.partner.id, + "journal_id": self.sale_journal.id, + "invoice_date": "2016-03-12", + "payment_mode_id": self.payment_mode.id, + "move_type": "out_invoice", + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.env.ref( + "product.product_delivery_02" + ).id, + "account_id": self.account.id, + "name": "Producto de prueba", + "quantity": 1.0, + "price_unit": 100.0, + "tax_ids": [(6, 0, self.tax.ids)], + }, + ) + ], + } + ) + self.main_company = self.env.ref("base.main_company") + self.main_company.face_email = "test@test.com" + self.face_update_type = self.env.ref( + "l10n_es_facturae_face.facturae_face_update_exchange_type" + ) + + # Don't block external requests. + @classmethod + def _request_handler(cls, s, r, /, **kw): + return cls._super_send(s, r, **kw) + + def test_constrain_company_mail(self): + with self.assertRaises(exceptions.ValidationError): + self.main_company.face_email = "test" + + def test_constrain_partner_facturae(self): + with self.assertRaises(exceptions.ValidationError): + self.partner.facturae = False + + def test_constrain_partner_vat(self): + with self.assertRaises(exceptions.ValidationError): + self.partner.vat = False + + def test_constrain_partner_country(self): + with self.assertRaises(exceptions.ValidationError): + self.partner.country_id = False + + def test_constrain_partner_spain_no_state(self): + with self.assertRaises(exceptions.ValidationError): + self.partner.state_id = False + + def test_facturae_face_error(self): + self._activate_certificate(self.certificate_password) + self.assertFalse(self.move.exchange_record_ids) + self.move.with_context( + force_edi_send=True, test_queue_job_no_delay=True + ).action_post() + self.move.invalidate_recordset() + self.assertTrue(self.move.exchange_record_ids) + exchange_record = self.move.exchange_record_ids + self.assertEqual(exchange_record.edi_exchange_state, "output_pending") + exchange_record.backend_id.exchange_send(exchange_record) + self.assertEqual(exchange_record.edi_exchange_state, "output_error_on_send") + + def test_create_facturae_file_without_organo_gestor(self): + self._activate_certificate(self.certificate_password) + self.move.action_post() + self.move.name = "2999/99999" + wizard = ( + self.env["create.facturae"] + .with_context(active_ids=self.move.ids, active_model="account.move") + .create({}) + ) + self.partner.organo_gestor = False + with self.assertRaises(exceptions.ValidationError): + wizard.create_facturae_file() + + def test_facturae_face_0(self): + class DemoService: + def __init__(self, value): + self.value = value + + def enviarFactura(self, *args): + return self.value + + def anularFactura(self, *args): + return self.value + + def consultarFactura(self, *args): + return self.value + + def consultarListadoFacturas(self, *args): + return self.value + + self._activate_certificate(self.certificate_password) + client = Client( + wsdl=self.env["ir.config_parameter"].sudo().get_param("facturae.face.ws") + ) + integration_code = "1234567890" + response_ok = client.get_type("ns0:EnviarFacturaResponse")( + client.get_type("ns0:Resultado")(codigo="0", descripcion="OK"), + client.get_type("ns0:EnviarFactura")(numeroRegistro=integration_code), + ) + self.assertFalse(self.move.exchange_record_ids) + with mock.patch("zeep.client.ServiceProxy") as mock_client: + mock_client.return_value = DemoService(response_ok) + + self.move.with_context( + force_edi_send=True, test_queue_job_no_delay=True + ).action_post() + self.move.name = "2999/99998" + mock_client.assert_not_called() + exchange_record = self.move.exchange_record_ids.with_context( + _edi_send_break_on_error=True + ) + self.assertEqual(exchange_record.edi_exchange_state, "output_pending") + exchange_record.backend_id.exchange_send(exchange_record) + self.assertEqual( + exchange_record.edi_exchange_state, "output_sent_and_processed" + ) + mock_client.assert_called_once() + self.move.invalidate_recordset() + self.assertTrue(self.move.exchange_record_ids) + self.assertIn( + str(self.face_update_type.id), + self.move.edi_config, + ) + with self.assertRaises(exceptions.UserError): + self.move.edi_create_exchange_record(self.face_update_type.id) + + def test_facturae_face(self): + class DemoService: + def __init__(self, value): + self.value = value + + def enviarFactura(self, *args): + return self.value + + def anularFactura(self, *args): + return self.value + + def consultarFactura(self, *args): + return self.value + + def consultarListadoFacturas(self, *args): + return self.value + + self._activate_certificate(self.certificate_password) + client = Client( + wsdl=self.env["ir.config_parameter"].sudo().get_param("facturae.face.ws") + ) + integration_code = "1234567890" + response_ok = client.get_type("ns0:EnviarFacturaResponse")( + client.get_type("ns0:Resultado")(codigo="0", descripcion="OK"), + client.get_type("ns0:EnviarFactura")(numeroRegistro=integration_code), + ) + self.assertFalse(self.move.exchange_record_ids) + with mock.patch("zeep.client.ServiceProxy") as mock_client: + mock_client.return_value = DemoService(response_ok) + + self.move.with_context( + force_edi_send=True, test_queue_job_no_delay=True + ).action_post() + self.move.name = "2999/99998" + mock_client.assert_not_called() + exchange_record = self.move.exchange_record_ids.with_context( + _edi_send_break_on_error=True + ) + self.assertEqual(exchange_record.edi_exchange_state, "output_pending") + exchange_record.backend_id.exchange_send(exchange_record) + self.assertEqual( + exchange_record.edi_exchange_state, "output_sent_and_processed" + ) + mock_client.assert_called_once() + self.move.invalidate_recordset() + self.assertTrue(self.move.exchange_record_ids) + exchange_record = self.move.exchange_record_ids + response_update = client.get_type("ns0:ConsultarFacturaResponse")( + client.get_type("ns0:Resultado")(codigo="0", descripcion="OK"), + client.get_type("ns0:ConsultarFactura")( + "1234567890", + client.get_type("ns0:EstadoFactura")("1200", "DESC", "MOTIVO"), + client.get_type("ns0:EstadoFactura")("4100", "DESC", "MOTIVO"), + ), + ) + self.move.invalidate_recordset() + self.assertIn( + str(self.face_update_type.id), + self.move.edi_config, + ) + try: + self.move.edi_create_exchange_record(self.face_update_type.id) + except exceptions.UserError: # pylint: disable=W8138 + pass + except Exception: + raise + + with mock.patch("zeep.client.ServiceProxy") as mock_client: + mock_client.return_value = DemoService(response_update) + self.move.edi_create_exchange_record(self.face_update_type.id) + mock_client.assert_called_once() + self.assertEqual(exchange_record.l10n_es_facturae_status, "face-1200") + self.assertEqual(self.move.l10n_es_facturae_status, "face-1200") + # On the second update, no new logs are generated + multi_response = client.get_type("ns0:ConsultarListadoFacturaResponse")( + client.get_type("ns0:Resultado")(codigo="0", descripcion="OK"), + client.get_type("ns0:ArrayOfConsultarListadoFactura")( + [ + client.get_type("ns0:ConsultarListadoFactura")( + codigo="0", + descripcion="OK", + factura=client.get_type("ns0:ConsultarFactura")( + "1234567890", + client.get_type("ns0:EstadoFactura")( + "1300", "DESC", "MOTIVO" + ), + client.get_type("ns0:EstadoFactura")( + "4100", "DESC", "MOTIVO" + ), + ), + ) + ] + ), + ) + + with mock.patch("zeep.client.ServiceProxy") as mock_client: + mock_client.return_value = DemoService(multi_response) + self.env["edi.exchange.record"].with_context()._cron_face_update_method() + exchange_record.flush_recordset() + exchange_record.invalidate_recordset() + self.assertEqual(exchange_record.l10n_es_facturae_status, "face-1300") + + self.assertEqual(len(exchange_record.related_exchange_ids), 3) + with mock.patch("zeep.client.ServiceProxy") as mock_client: + mock_client.return_value = DemoService(multi_response) + self.env["edi.exchange.record"].with_context()._cron_face_update_method() + exchange_record.flush_recordset() + exchange_record.invalidate_recordset() + self.assertEqual(len(exchange_record.related_exchange_ids), 3) + # New record should not have been created + cancel = self.env["edi.l10n.es.facturae.face.cancel"].create( + {"move_id": self.move.id, "motive": "Anulacion"} + ) + with self.assertRaises(exceptions.UserError): + cancel.cancel_face() + response_cancel = client.get_type("ns0:ConsultarFacturaResponse")( + client.get_type("ns0:Resultado")("0", "OK"), + client.get_type("ns0:AnularFactura")("1234567890", "ANULADO"), + ) + with mock.patch("zeep.client.ServiceProxy") as mock_client: + mock_client.return_value = DemoService(response_cancel) + cancel.cancel_face() + exchange_record.invalidate_recordset() + self.assertEqual( + exchange_record.l10n_es_facturae_cancellation_status, "face-4200" + ) + self.assertEqual(self.move.l10n_es_facturae_cancellation_status, "face-4200") diff --git a/l10n_es_facturae_face/views/account_move.xml b/l10n_es_facturae_face/views/account_move.xml new file mode 100644 index 00000000000..772a3a4d17d --- /dev/null +++ b/l10n_es_facturae_face/views/account_move.xml @@ -0,0 +1,25 @@ + + + + + account.move.form + account.move + + + + + + + + + + diff --git a/l10n_es_facturae_face/views/edi_exchange_record.xml b/l10n_es_facturae_face/views/edi_exchange_record.xml new file mode 100644 index 00000000000..0db8569ab44 --- /dev/null +++ b/l10n_es_facturae_face/views/edi_exchange_record.xml @@ -0,0 +1,28 @@ + + + + + edi.exchange.record.form (in l10n_es_facturae_face) + edi.exchange.record + + + + + + + + + + + + + + + + + diff --git a/l10n_es_facturae_face/views/res_company_view.xml b/l10n_es_facturae_face/views/res_company_view.xml new file mode 100644 index 00000000000..f7c6ecbc782 --- /dev/null +++ b/l10n_es_facturae_face/views/res_company_view.xml @@ -0,0 +1,14 @@ + + + + res.company.form + res.company + + form + + + + + + + diff --git a/l10n_es_facturae_face/views/res_partner.xml b/l10n_es_facturae_face/views/res_partner.xml new file mode 100644 index 00000000000..1028ae09e57 --- /dev/null +++ b/l10n_es_facturae_face/views/res_partner.xml @@ -0,0 +1,24 @@ + + + + + res.partner.form + res.partner + + + + + + + + + + + diff --git a/l10n_es_facturae_face/wizards/__init__.py b/l10n_es_facturae_face/wizards/__init__.py new file mode 100644 index 00000000000..6d5aa33f55d --- /dev/null +++ b/l10n_es_facturae_face/wizards/__init__.py @@ -0,0 +1 @@ +from . import edi_l10n_es_facturae_face_cancel diff --git a/l10n_es_facturae_face/wizards/edi_l10n_es_facturae_face_cancel.py b/l10n_es_facturae_face/wizards/edi_l10n_es_facturae_face_cancel.py new file mode 100644 index 00000000000..6adb85b4302 --- /dev/null +++ b/l10n_es_facturae_face/wizards/edi_l10n_es_facturae_face_cancel.py @@ -0,0 +1,35 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json + +from odoo import fields, models + + +class EdiL10nEsFacturaeFaceCancel(models.TransientModel): + _name = "edi.l10n.es.facturae.face.cancel" + _description = "Cancel a FACe Exchange Record" + + move_id = fields.Many2one("account.move", required=True) + motive = fields.Char(required=True) + + def cancel_face(self): + self.ensure_one() + backend = self.env.ref("l10n_es_facturae_face.face_backend") + exchange_type = self.env.ref("l10n_es_facturae_face.facturae_exchange_type") + exchange_record = self.move_id._get_exchange_record(exchange_type, backend) + exchange_record.ensure_one() + cancel_exchange_record = backend.create_record( + "l10n_es_facturae_face_cancel", + { + "model": self.move_id._name, + "res_id": self.move_id.id, + "parent_id": exchange_record.id, + "edi_exchange_state": "output_pending", + }, + ) + cancel_exchange_record._set_file_content(json.dumps({"motive": self.motive})) + backend.with_context(_edi_send_break_on_error=True).exchange_send( + cancel_exchange_record + ) + return {} diff --git a/l10n_es_facturae_face/wizards/edi_l10n_es_facturae_face_cancel.xml b/l10n_es_facturae_face/wizards/edi_l10n_es_facturae_face_cancel.xml new file mode 100644 index 00000000000..15fe126e3af --- /dev/null +++ b/l10n_es_facturae_face/wizards/edi_l10n_es_facturae_face_cancel.xml @@ -0,0 +1,38 @@ + + + + + edi.l10n.es.facturae.face.cancel.form (in l10n_es_facturae_face) + edi.l10n.es.facturae.face.cancel + +
+ + + + +
+
+
+
+
+ + Cancel FACe + edi.l10n.es.facturae.face.cancel + form + {} + new + +
diff --git a/requirements.txt b/requirements.txt index 262510332b3..0b543b25f26 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ pycountry pycryptodome unidecode xmlsig +zeep