wpint: Raise exception if creating shipping label fails for some reason

This commit is contained in:
Harald Welte 2021-03-18 18:03:00 +01:00
parent 2ae2229576
commit 3ebb9425d0
1 changed files with 3 additions and 0 deletions

View File

@ -195,6 +195,9 @@ class DPDeliveryCarrier(models.Model):
'EUR', customer_reference=pickings.name, contents=wpi_content)
# actually create the order + download the label
wpi_res = wpi.api_create_order([wpi_item], 'Max Mustermann')
if not 'shipments' in wpi_res:
_logger.error("Warenpost International failed to create shipment: %s", wpi_res)
raise Warning("Warenpost International failed to create shipment: %s", wpi_res)
wpi_res_item = wpi_res['shipments'][0]['items'][0]
png = wpi.api_get_item_label(wpi_res_item['id'], 'image/png')
# build result dict