[FIX] delivery_gls_nl: pdf data is base64 encoded

This commit is contained in:
Jared Kipe
2022-02-20 18:21:33 +00:00
parent 56c151af09
commit 723b95a6e8

View File

@@ -2,7 +2,7 @@ from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from .gls_nl_request import GLSNLRequest
from requests import HTTPError
from base64 import decodebytes
from base64 import decodebytes, b64decode
from csv import reader as csv_reader
@@ -261,7 +261,10 @@ class ProviderGLSNL(models.Model):
for i, unit in enumerate(label['units'], 1):
trackings.append(unit['unitNo'])
uniq_nos.append(unit['uniqueNo'])
attachments.append(('LabelGLSNL-%s-%s.%s' % (unit['unitNo'], i, sudoself.gls_nl_labeltype), unit['label']))
label_data = unit['label']
if label_data and sudoself.gls_nl_labeltype == 'pdf':
label_data = b64decode(label_data)
attachments.append(('LabelGLSNL-%s-%s.%s' % (unit['unitNo'], i, sudoself.gls_nl_labeltype), label_data))
tracking = ', '.join(set(trackings))
logmessage = _("Shipment created into GLS NL<br/>"