changeset 472a5c06ee88 in modules/stock_package_shipping_ups:default
details: 
https://hg.tryton.org/modules/stock_package_shipping_ups?cmd=changeset&node=472a5c06ee88
description:
        Add wizard to print shipping labels

        issue10834
        review375701002
diffstat:

 carrier.py                      |  8 ++++++++
 stock.py                        |  3 +++
 tests/scenario_shipping_ups.rst |  2 ++
 3 files changed, 13 insertions(+), 0 deletions(-)

diffs (47 lines):

diff -r b545cfac2595 -r 472a5c06ee88 carrier.py
--- a/carrier.py        Tue Oct 05 12:45:39 2021 +0200
+++ b/carrier.py        Mon Oct 11 18:50:11 2021 +0200
@@ -103,3 +103,11 @@
                     '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 -r b545cfac2595 -r 472a5c06ee88 stock.py
--- a/stock.py  Tue Oct 05 12:45:39 2021 +0200
+++ b/stock.py  Mon Oct 11 18:50:11 2021 +0200
@@ -173,6 +173,7 @@
                     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 @@
                     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 -r b545cfac2595 -r 472a5c06ee88 tests/scenario_shipping_ups.rst
--- a/tests/scenario_shipping_ups.rst   Tue Oct 05 12:45:39 2021 +0200
+++ b/tests/scenario_shipping_ups.rst   Mon Oct 11 18:50:11 2021 +0200
@@ -223,6 +223,8 @@
     >>> 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?')

Reply via email to