mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[FIX] delivery_gso: paper label handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import pytz
|
import pytz
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
from base64 import b64decode
|
||||||
from requests import HTTPError
|
from requests import HTTPError
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
|
||||||
@@ -13,6 +14,13 @@ _logger = logging.getLogger(__name__)
|
|||||||
GSO_TZ = 'PST8PDT'
|
GSO_TZ = 'PST8PDT'
|
||||||
|
|
||||||
|
|
||||||
|
def inline_b64decode(data):
|
||||||
|
try:
|
||||||
|
return b64decode(data)
|
||||||
|
except:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class ProductPackaging(models.Model):
|
class ProductPackaging(models.Model):
|
||||||
_inherit = 'product.packaging'
|
_inherit = 'product.packaging'
|
||||||
|
|
||||||
@@ -228,7 +236,7 @@ class ProviderGSO(models.Model):
|
|||||||
raise ValidationError(e)
|
raise ValidationError(e)
|
||||||
|
|
||||||
# Handle results
|
# Handle results
|
||||||
trackings = [l[0] for l in labels['thermal']] + [l(0) for l in labels['paper']]
|
trackings = [l[0] for l in labels['thermal']] + [l[0] for l in labels['paper']]
|
||||||
carrier_tracking_ref = ','.join(trackings)
|
carrier_tracking_ref = ','.join(trackings)
|
||||||
|
|
||||||
logmessage = _("Shipment created into GSO<br/>"
|
logmessage = _("Shipment created into GSO<br/>"
|
||||||
@@ -237,7 +245,8 @@ class ProviderGSO(models.Model):
|
|||||||
if labels['thermal']:
|
if labels['thermal']:
|
||||||
attachments += [('LabelGSO-%s.zpl' % (l[0], ), l[1]) for l in labels['thermal']]
|
attachments += [('LabelGSO-%s.zpl' % (l[0], ), l[1]) for l in labels['thermal']]
|
||||||
if labels['paper']:
|
if labels['paper']:
|
||||||
attachments += [('LabelGSO-%s.pdf' % (l[0], ), l[1]) for l in labels['thermal']]
|
# paper labels re-encoded base64
|
||||||
|
attachments += [('LabelGSO-%s.png' % (l[0], ), inline_b64decode(l[1])) for l in labels['paper']]
|
||||||
picking.message_post(body=logmessage, attachments=attachments)
|
picking.message_post(body=logmessage, attachments=attachments)
|
||||||
shipping_data = {'exact_price': cost,
|
shipping_data = {'exact_price': cost,
|
||||||
'tracking_number': carrier_tracking_ref}
|
'tracking_number': carrier_tracking_ref}
|
||||||
|
|||||||
Reference in New Issue
Block a user