Skip to content
Closed
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
7 changes: 7 additions & 0 deletions l10n_uy_ux/i18n/es_419.po
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ msgstr "Tipo de Documento"
msgid "Electronic Fiscal Document (CFE - UY)"
msgstr "Documento Fiscal Electrónico (CFE - UY)"

#. module: l10n_uy_ux
#. odoo-python
#: code:addons/l10n_uy_ux/models/account_move.py:0
#, python-format
msgid "Errors occurred while evaluating the document: \n"
msgstr "Errores ocurridos al evaluar el documento: \n"

Comment on lines +186 to +192
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se agregó la traducción solo en es_419.po, pero el mismo msgid no está presente en l10n_uy_ux/i18n/es.po. Si están manteniendo ambos catálogos, convendría exportar/actualizar también es.po (aunque sea con msgstr vacío) para que no quede desincronizado.

Copilot uses AI. Check for mistakes.
#. module: l10n_uy_ux
#. odoo-python
#: code:addons/l10n_uy_ux/models/account_move.py:0
Expand Down
32 changes: 27 additions & 5 deletions l10n_uy_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

from lxml import etree
from markupsafe import Markup
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools import safe_eval
Expand Down Expand Up @@ -55,6 +56,28 @@ def _l10n_uy_edi_check_move(self):

return errors

def _l10n_uy_edi_send(self):
"""Antes de enviar a DGI, corremos los chequeos previos para atrapar algunos errores conocidos y de fácil configuración.
Si obtenemos alguno, no continuamos con el envío a DGI y en cambio creamos el XML con el error."""
moves_to_send = self
for move in self:
move.l10n_uy_edi_document_id.filtered(lambda doc: doc.state == "error").unlink()
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En este punto el .unlink() sobre documentos en estado error probablemente no elimina nada: en l10n_uy_ux/models/l10n_uy_edi_document.py el unlink() está sobreescrito para preservar documentos con message/l10n_uy_edi_error, por lo que acá quedarían documentos huérfanos. Alternativas: eliminar esta línea si se quiere preservar historial, o permitir el borrado explícito vía context (p.ej. allow_unlink_error_docs) y respetarlo en el override de unlink().

Suggested change
move.l10n_uy_edi_document_id.filtered(lambda doc: doc.state == "error").unlink()
move.l10n_uy_edi_document_id.filtered(lambda doc: doc.state == "error").with_context(
allow_unlink_error_docs=True
).unlink()

Copilot uses AI. Check for mistakes.
edi_doc = self.env["l10n_uy_edi.document"].create(
{
"move_id": move.id,
"uuid": self.env["l10n_uy_edi.document"]._get_uuid(move),
}
)
Comment thread
jue-adhoc marked this conversation as resolved.
move.l10n_uy_edi_document_id = edi_doc
if pre_checks_errors := move._l10n_uy_edi_check_move():
edi_doc.message = self.env._("Errors occurred while evaluating the document: \n") + "\n *".join(
Comment thread
jue-adhoc marked this conversation as resolved.
pre_checks_errors
Comment on lines +73 to +74
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La construcción del mensaje arma el listado de errores con "\n *".join(...), lo que deja el primer error sin viñeta (queda pegado al header) y sin espacio consistente. Para que el formato sea estable, conviene prefijar el listado con \n * y luego hacer el join con el mismo separador.

Suggested change
edi_doc.message = self.env._("Errors occurred while evaluating the document: \n") + "\n *".join(
pre_checks_errors
edi_doc.message = (
self.env._("Errors occurred while evaluating the document: \n")
+ "\n * "
+ "\n * ".join(pre_checks_errors)

Copilot uses AI. Check for mistakes.
)
edi_doc.state = "error"
moves_to_send -= move

super(AccountMove, moves_to_send)._l10n_uy_edi_send()
Comment on lines +59 to +79
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este cambio modifica el flujo de posteo/envío: ya no se levanta ValidationError en pre-checks y en su lugar se crea un l10n_uy_edi.document en state='error' y se revierte a borrador. Hay tests en l10n_uy_ux/tests, pero no hay cobertura para este nuevo comportamiento; estaría bueno agregar un test que fuerce un error de _l10n_uy_edi_check_move() y verifique que no se raisea excepción, que se crea el documento EDI con mensaje y que el move queda fuera de res.

Copilot generated this review using guidance from repository custom instructions.

def _post(self, soft=True):
"""Extendemos el _post nativo para evitar hacer la confirmación en dos pasos con el wizard de Send & Print.
De esta manera, al clickear en confirmar las facturas automáticamente serán enviadas a DGI y posteadas.
Expand All @@ -66,13 +89,12 @@ def _post(self, soft=True):
return res
msg = self.env._("Error al intentar validar el documento en DGI")
for move in res.filtered(lambda m: m.l10n_uy_edi_is_needed):
if pre_checks_errors := move._l10n_uy_edi_check_move():
raise ValidationError(
self.env._("Errors occurred while evaluating the document: \n") + "\n".join(pre_checks_errors)
)
move._l10n_uy_edi_send()
if move.l10n_uy_edi_error:
move.message_post(body=msg + " %s" % (move.l10n_uy_edi_error))
error_msg = Markup("<font style='color:Tomato;'><strong>ERROR:</strong></font> <i>{}</i>").format(
f"{msg}: {move.l10n_uy_edi_error}"
)
move.message_post(body=error_msg, body_is_html=True)
Comment on lines +94 to +97
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El banner agrega el literal "ERROR:" hardcodeado en inglés y en HTML. Si esto es visible al usuario, debería ser traducible (p.ej. usando _()/env._()) para no mezclar idiomas en el chatter/banner.

Copilot uses AI. Check for mistakes.
move.button_draft()
res = res - move
return res
Expand Down
Loading