From 919dfca45566902d257ff2f6bb5f941ee7ca1d51 Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Mon, 27 Jun 2022 11:52:06 +0000 Subject: [PATCH] [IMP] l10n_es_edi_sii: clearer missing element TipoDesglose error When sending an invoice to the SII edi, the field TipoDesglose is required. In case we have a foreign customer outside of Spain, we are filtering the taxes information based on the tax scope (services or goods). In case the tax scope is not filled in, TipoDesglose is not provided and this will cause the request to fail, with no clear reason for the user. We should add an UserError message to make it clear enough so the user can fix it himself. closes odoo/odoo#95164 X-original-commit: 7a6b3544d7c3a855489a0d5f7075691e25264e2d Signed-off-by: Florian Gilbert (flg) Signed-off-by: Alex Thuyls (alt) --- addons/l10n_es_edi_sii/models/account_edi_format.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/l10n_es_edi_sii/models/account_edi_format.py b/addons/l10n_es_edi_sii/models/account_edi_format.py index 4b831015b5b..708fc93318a 100644 --- a/addons/l10n_es_edi_sii/models/account_edi_format.py +++ b/addons/l10n_es_edi_sii/models/account_edi_format.py @@ -6,6 +6,7 @@ from OpenSSL.crypto import load_certificate, load_privatekey, FILETYPE_PEM from zeep.transports import Transport from odoo import fields, models, _ +from odoo.exceptions import UserError from odoo.tools import html_escape import math @@ -348,6 +349,11 @@ class AccountEdiFormat(models.Model): invoice_node.setdefault('TipoDesglose', {}) invoice_node['TipoDesglose'].setdefault('DesgloseTipoOperacion', {}) invoice_node['TipoDesglose']['DesgloseTipoOperacion']['Entrega'] = tax_details_info_consu_vals['tax_details_info'] + if not invoice_node.get('TipoDesglose'): + raise UserError(_( + "In case of a foreign customer, you need to configure the tax scope on taxes:\n%s", + "\n".join(invoice.line_ids.tax_ids.mapped('name')) + )) invoice_node['ImporteTotal'] = round(sign * ( tax_details_info_service_vals['tax_details']['base_amount']