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

[14.0][FIX] l10n_it_fatturapa_in: attachments were encoded two times #2446

Merged
merged 1 commit into from
Oct 22, 2021
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
4 changes: 1 addition & 3 deletions l10n_it_fatturapa_in/models/attachment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import base64

from odoo import _, api, fields, models
from odoo.tools import format_date

Expand Down Expand Up @@ -135,7 +133,7 @@ def extract_attachments(self, AttachmentsData, invoice_id):
content = attach.Attachment.encode()
_attach_dict = {
"name": name,
"datas": base64.b64encode(content),
"datas": content,
"description": attach.DescrizioneAttachment or "",
"compression": attach.AlgoritmoCompressione or "",
"format": attach.FormatoAttachment or "",
Expand Down
Binary file added l10n_it_fatturapa_in/tests/data/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from psycopg2 import IntegrityError

from odoo.exceptions import UserError
from odoo.modules import get_module_resource
from odoo.tests import Form
from odoo.tools import mute_logger

Expand Down Expand Up @@ -103,6 +104,17 @@ def test_01_xml_import(self):
self.assertEqual(invoice.ftpa_incoterms, "DAP")
self.assertEqual(invoice.fiscal_document_type_id.code, "TD01")
self.assertTrue(invoice.art73)

# verify if attached documents are correctly imported
attachments = invoice.fatturapa_doc_attachments
self.assertEqual(len(attachments), 1)
orig_attachment_path = get_module_resource(
"l10n_it_fatturapa_in", "tests", "data", "test.png"
)
with open(orig_attachment_path, "rb") as orig_attachment:
orig_attachment_data = orig_attachment.read()
self.assertEqual(attachments[0].raw, orig_attachment_data)

# allow following tests to reuse the same XML file
invoice.ref = invoice.payment_reference = "14011"

Expand Down