Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions l10n_es_aeat_sii_oca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import json
import logging

from unidecode import unidecode

from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.modules.registry import Registry
Expand Down Expand Up @@ -679,6 +681,7 @@ def _compute_sii_description(self):
names = invoice.mapped("invoice_line_ids.name") or invoice.mapped(
"invoice_line_ids.ref"
)
names = [unidecode(x) for x in names] # Avoid "ugly" chars
description += " - ".join(filter(None, names))
invoice.sii_description = (description or "")[:500] or "/"

Expand Down
11 changes: 7 additions & 4 deletions l10n_es_aeat_sii_oca/models/sii_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Copyright 2011,2024 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import json
import logging

from unidecode import unidecode

from odoo import api, exceptions, fields, models
from odoo.exceptions import UserError, ValidationError
Expand All @@ -14,8 +15,6 @@

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

_logger = logging.getLogger(__name__)

SII_STATES = [
("sent_modified", "Registered in SII but last modifications not sent"),
("cancelled", "Cancelled"),
Expand All @@ -35,7 +34,7 @@ class SiiMixin(models.AbstractModel):
comodel_name="res.company",
string="Company",
)
sii_description = fields.Text(
sii_description = fields.Char(
string="SII computed description",
compute="_compute_sii_description",
default="/",
Expand Down Expand Up @@ -797,6 +796,10 @@ def _send_document_to_sii(self):
for document in self.filtered(
lambda i: i.state in self._get_valid_document_states()
):
# Filter the SII description for avoiding manual invalid inputs
text = unidecode(document.sii_description)
if text != document.sii_description:
document.sii_description = text
if document.aeat_state == "not_sent":
tipo_comunicacion = "A0"
else:
Expand Down