Skip to content

Commit e3b4e74

Browse files
committed
Merge PR #4865 into 18.0
Signed-off-by pedrobaeza
2 parents 0f7d117 + fc61daa commit e3b4e74

2 files changed

Lines changed: 10 additions & 4 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: 7 additions & 4 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"),
@@ -35,7 +34,7 @@ class SiiMixin(models.AbstractModel):
3534
comodel_name="res.company",
3635
string="Company",
3736
)
38-
sii_description = fields.Text(
37+
sii_description = fields.Char(
3938
string="SII computed description",
4039
compute="_compute_sii_description",
4140
default="/",
@@ -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)