-
Notifications
You must be signed in to change notification settings - Fork 7
[FIX] l10n_uy_ux: enhance EDI sending process with pre-checks and error handling #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||
|
|
@@ -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() | ||||||||||||||
|
||||||||||||||
| 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
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
| 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
AI
Jan 27, 2026
There was a problem hiding this comment.
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
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 mismomsgidno está presente enl10n_uy_ux/i18n/es.po. Si están manteniendo ambos catálogos, convendría exportar/actualizar tambiénes.po(aunque sea conmsgstrvacío) para que no quede desincronizado.