Add wizard to print shipping labels
issue10834 review375701002
This commit is contained in:
1 parent
91a51958c6
commit
f6bc5faeab
3 files changed
+12
No files matched your search
@@ -107,3 +107,10 @@ class Carrier(metaclass=PoolMeta):
|
||||
'invisible': Eval('shipping_service') != 'dpd',
|
||||
}),
|
||||
]
|
||||
|
||||
@property
|
||||
def shipping_label_mimetype(self):
|
||||
mimetype = super().shipping_label_mimetype
|
||||
if self.shipping_service == 'dpd':
|
||||
mimetype = 'application/pdf'
|
||||
return mimetype
|
||||
@@ -124,6 +124,7 @@ class CreateDPDShipping(Wizard):
|
||||
if not credential.depot or not credential.token:
|
||||
credential.update_token()
|
||||
|
||||
carrier = shipment.carrier
|
||||
shipping_client = get_client(credential.server, SHIPMENT_SERVICE)
|
||||
print_options = self.get_print_options(shipment)
|
||||
packages = shipment.root_packages
|
||||
@@ -178,6 +179,8 @@ class CreateDPDShipping(Wizard):
|
||||
parcels = response.parcelInformation
|
||||
for package, label, parcel in zip_longest(packages, labels, parcels):
|
||||
package.shipping_label = fields.Binary.cast(label.getvalue())
|
||||
package.shipping_label_mimetype = (
|
||||
carrier.shipping_label_mimetype)
|
||||
package.shipping_reference = parcel.parcelLabelNumber
|
||||
Package.save(packages)
|
||||
shipment.save()
|
||||
|
||||
@@ -221,6 +221,8 @@ Create the packs and ship the shipment::
|
||||
>>> pack, = shipment.root_packages
|
||||
>>> pack.shipping_label is not None
|
||||
True
|
||||
>>> pack.shipping_label_mimetype
|
||||
'application/pdf'
|
||||
>>> pack.shipping_reference is not None
|
||||
True
|
||||
>>> pack.shipping_tracking_url.startswith('https://tracking.dpd.de/status/')
|
||||
|
||||
Reference in new issue
Block a user