Skip to Content

Name: [FIX] l10n_vn_edi_viettel: fetch only the missing SInvoice files on re-send

State: Killed finished in 310m

PR State: merged

PR Author: David Tran

PR Author Email:

PR: #1330

Committer: David Tran

Committer Email: david.tran@tvtmarine.com

Commit: 2cd94b9d9f40b37f9ad30eacca253b0b50650a1b

Description:

                                            [FIX] l10n_vn_edi_viettel: fetch only the missing SInvoice files on re-send

Steps to reproduce:
- Send & Print a posted customer invoice with "Send to SInvoice" ticked:
  the invoice is issued and its PDF and XML files are fetched from
  SInvoice and stored on the invoice.
- Send & Print the same invoice again, for instance to email it to the
  customer.

Current behavior:
`_call_web_service_after_invoice_pdf_render` calls
`_l10n_vn_edi_fetch_invoice_files` for every invoice already sent, so
both files are fetched from SInvoice again on every Send & Print. Each
run creates a second attachment on the same binary field and posts a
new "Invoice sent to SInvoice" note in the chatter.

Besides, when SInvoice answers with an empty `fileToBytes`, the retry
loop gives up and the empty content is stored as the PDF file; a reply
without the `fileToBytes` key raises a KeyError in that loop, and a
reply that is not a ZIP archive raises zipfile.BadZipFile out of
`_l10n_vn_edi_fetch_invoice_xml_file_data`.

After this commit:
A file already stored on the invoice is not fetched again; only a
missing one is. An empty reply, a reply without the file key and a
non-ZIP reply are returned as error messages, which Send & Print shows
on the invoice like the other SInvoice errors. The two new messages are
added to the translation template and the Vietnamese catalog.

Closes Viindoo/odoo#1328
                                            

Branch: 18.0

Age:

Up-time: