diff --git a/carrier.py b/carrier.py index bf646d7e5f..a7e5b040ed 100644 --- a/carrier.py +++ b/carrier.py @@ -103,3 +103,11 @@ class Carrier(metaclass=PoolMeta): 'invisible': Eval('shipping_service') != 'ups', }), ] + + @property + def shipping_label_mimetype(self): + mimetype = super().shipping_label_mimetype + if self.shipping_service == 'ups': + if self.ups_label_image_format == 'GIF': + mimetype = 'image/gif' + return mimetype diff --git a/stock.py b/stock.py index 54cdaea03d..089abd73bb 100644 --- a/stock.py +++ b/stock.py @@ -173,6 +173,7 @@ class CreateShippingUPS(Wizard): shipment=shipment.rec_name)) credential = self.get_credential(shipment) + carrier = shipment.carrier packages = shipment.root_packages shipment_request = self.get_request(shipment, packages, credential) api_url = config.get('stock_package_shipping_ups', credential.server, @@ -227,6 +228,8 @@ class CreateShippingUPS(Wizard): ups_pkg['ShippingLabel']['GraphicImage'])) tryton_pkg.shipping_reference = ups_pkg['TrackingNumber'] tryton_pkg.shipping_label = label + tryton_pkg.shipping_label_mimetype = ( + carrier.shipping_label_mimetype) Package.save(packages) shipment.save() diff --git a/tests/scenario_shipping_ups.rst b/tests/scenario_shipping_ups.rst index f9bc5ede3c..39c2e0b206 100644 --- a/tests/scenario_shipping_ups.rst +++ b/tests/scenario_shipping_ups.rst @@ -223,6 +223,8 @@ Create the packs and ship the shipment:: >>> pack, = shipment.root_packages >>> pack.shipping_label is not None True + >>> pack.shipping_label_mimetype + 'image/gif' >>> pack.shipping_reference is not None True >>> pack.shipping_tracking_url.startswith('https://www.ups.com/track?')