Skip to content

Commit c1804a3

Browse files
Pedro M. BaezaEmilioPascual
authored andcommitted
[FIX] l10n_es_aeat_sii_oca: Don't send "ugly" chars
AEAT is not storing accented chars, ñ, ç, which is a bit sad being Spain... but for having a perfect match on contrast, we should decode the string and replace those characters. For that, we are using the same library as in `l10n_es_aeat`, which is unidecode.
1 parent d526ade commit c1804a3

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

l10n_es_aeat_sii_oca/models/account_move.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import json
1616
import logging
1717

18+
from unidecode import unidecode
19+
1820
from odoo import api, fields, models
1921
from odoo.exceptions import UserError
2022
from odoo.modules.registry import Registry
@@ -679,6 +681,7 @@ def _compute_sii_description(self):
679681
names = invoice.mapped("invoice_line_ids.name") or invoice.mapped(
680682
"invoice_line_ids.ref"
681683
)
684+
names = [unidecode(x) for x in names] # Avoid "ugly" chars
682685
description += " - ".join(filter(None, names))
683686
invoice.sii_description = (description or "")[:500] or "/"
684687

l10n_es_aeat_sii_oca/models/sii_mixin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# Copyright 2011,2024 Tecnativa - Pedro M. Baeza
66
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
77
import json
8-
import logging
8+
9+
from unidecode import unidecode
910

1011
from odoo import api, exceptions, fields, models
1112
from odoo.exceptions import UserError, ValidationError
@@ -14,8 +15,6 @@
1415

1516
from odoo.addons.l10n_es_aeat.models.aeat_mixin import round_by_keys
1617

17-
_logger = logging.getLogger(__name__)
18-
1918
SII_STATES = [
2019
("sent_modified", "Registered in SII but last modifications not sent"),
2120
("cancelled", "Cancelled"),
@@ -797,6 +796,10 @@ def _send_document_to_sii(self):
797796
for document in self.filtered(
798797
lambda i: i.state in self._get_valid_document_states()
799798
):
799+
# Filter the SII description for avoiding manual invalid inputs
800+
text = unidecode(document.sii_description)
801+
if text != document.sii_description:
802+
document.sii_description = text
800803
if document.aeat_state == "not_sent":
801804
tipo_comunicacion = "A0"
802805
else:

0 commit comments

Comments
 (0)