Skip to content
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

[IMP] l10n_it_fatturapa_out: errore più verboso nel caso di presenza di caratteri non validi #4390

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

tafaRU
Copy link
Member

@tafaRU tafaRU commented Oct 1, 2024

Risolve #4389 per 14.0.

@tafaRU
Copy link
Member Author

tafaRU commented Oct 1, 2024

I test falliscono a causa del modulo account_edi_ubl_cii che viene installato per una catena di auto_install che parte da accout_edi.
Riporto l'errore per esteso:

2024-10-01 13:45:11,833 600 ERROR odoo odoo.addons.l10n_it_fatturapa_out.tests.test_fatturapa_xml_validation: ERROR: TestFatturaPAXMLValidation.test_invalid_char_fail
Traceback (most recent call last):
  File "/__w/l10n-italy/l10n-italy/l10n_it_fatturapa_out/tests/test_fatturapa_xml_validation.py", line 952, in test_invalid_char_fail
    invoice._post()
  File "/__w/l10n-italy/l10n-italy/l10n_it_ricevute_bancarie/models/account.py", line 150, in _post
    return super()._post(soft=soft)
  File "/__w/l10n-italy/l10n-italy/l10n_it_declaration_of_intent/models/account_move.py", line 81, in _post
    posted = super()._post(soft)
  File "/__w/l10n-italy/l10n-italy/l10n_it_account_stamp/models/account_move.py", line 154, in _post
    res = super(AccountMove, self)._post(soft=soft)
  File "/opt/odoo/addons/sale/models/account_invoice.py", line 75, in _post
    posted = super()._post(soft)
  File "/opt/odoo/addons/purchase_stock/models/account_invoice.py", line 173, in _post
    return super()._post(soft)
  File "/opt/odoo/addons/stock_account/models/account_move.py", line 53, in _post
    posted = super()._post(soft)
  File "/opt/odoo-venv/lib/python3.6/site-packages/odoo/addons/account_invoice_inter_company/models/account_move.py", line 72, in _post
    res = super()._post(soft=soft)
  File "/opt/odoo/addons/account_edi/models/account_move.py", line 361, in _post
    posted.edi_document_ids._process_documents_no_web_services()
  File "/opt/odoo/addons/account_edi/models/account_edi_document.py", line 249, in _process_documents_no_web_services
    self._process_jobs(self._convert_to_old_jobs_format(jobs))
  File "/opt/odoo/addons/account_edi/models/account_edi_document.py", line 145, in _process_jobs
    self._process_job(documents, doc_type)
  File "/opt/odoo/addons/account_edi/models/account_edi_document.py", line 231, in _process_job
    edi_result = edi_format._post_invoice_edi(documents.move_id, test_mode=test_mode)
  File "/opt/odoo/addons/account_edi_ubl_cii/models/account_edi_format.py", line 112, in _post_invoice_edi
    xml_content, errors = builder._export_invoice(invoice)
  File "/opt/odoo/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py", line 242, in _export_invoice
    return etree.tostring(cleanup_xml_node(xml_content), xml_declaration=True, encoding='UTF-8'), set(errors)
  File "/opt/odoo/odoo/tools/xml_utils.py", line 107, in cleanup_xml_node
    xml_node = etree.fromstring(xml_node)
  File "src/lxml/lxml.etree.pyx", line 3213, in lxml.etree.fromstring (src/lxml/lxml.etree.c:79003)
  File "src/lxml/parser.pxi", line 1848, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:118334)
  File "src/lxml/parser.pxi", line 1736, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:117014)
  File "src/lxml/parser.pxi", line 1102, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:111258)
  File "src/lxml/parser.pxi", line 595, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:105102)
  File "src/lxml/parser.pxi", line 706, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:106810)
  File "src/lxml/parser.pxi", line 635, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:105664)
  File "<string>", line 40
lxml.etree.XMLSyntaxError: PCDATA invalid Char value 2, line 40, column 35

),
error=entry.message,
)
# when there is a char belong to
Copy link
Contributor

@TheMule71 TheMule71 Oct 2, 2024

Choose a reason for hiding this comment

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

I commenti sono in italiano nel resto del file. Magari facciamo una passata, e li traduciamo tutti.

Notare il commento sotto (282)

@@ -949,7 +949,7 @@ def test_invalid_char_fail(self):
# set invoice line label to https://www.ascii-code.com/character/%E2%90%82
char_code = 2
invoice.invoice_line_ids.name = chr(char_code)
invoice._post()
invoice.with_context(edi_test_mode=True)._post()
Copy link
Contributor

Choose a reason for hiding this comment

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

Buono per la 14, ma non per le successive
odoo/odoo@22e04c6

Copy link
Member Author

@tafaRU tafaRU Oct 2, 2024

Choose a reason for hiding this comment

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

ok grazie, in realtà non mi è utile nemmeno qui perché non viene propagato fino a questo punto. Alla fine ho dovuto optare per un'altra soluzione: intercettare l'eccezione specifica sollevata da account_edi_ubl_cii e fare pass. See the code!

@tafaRU tafaRU force-pushed the 14.0-imp-l10n_it_fatturapa_out branch 2 times, most recently from acc7a3c to 4544204 Compare October 2, 2024 13:03
In case XMLParser raises an error as ERR_INVALID_CHAR the system will produce a more meaningful and human-readable error showing the line affected in order to more easily identify the invalid char.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

l10n_it_fatturapa_out: errore più verboso nel caso di presenza di caratteri non validi
3 participants