From 54e13ad7805ac6c60bf0eb1dd292574a4825dbf3 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Wed, 31 Aug 2022 22:15:30 +0000 Subject: [PATCH] [IMP] delivery_stamps: if customs form, change label print speed --- delivery_stamps/models/delivery_stamps.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/delivery_stamps/models/delivery_stamps.py b/delivery_stamps/models/delivery_stamps.py index cd721f6d..9b8c5d1a 100644 --- a/delivery_stamps/models/delivery_stamps.py +++ b/delivery_stamps/models/delivery_stamps.py @@ -335,6 +335,7 @@ class ProviderStamps(models.Model): def stamps_send_shipping(self, pickings): res = [] service = self._get_stamps_service() + had_customs = False for picking in pickings: package_labels = [] @@ -347,6 +348,7 @@ class ProviderStamps(models.Model): customs = None if self._stamps_needs_customs(from_partner, to_partner, picking=picking): customs = service.create_customs() + had_customs = bool(had_customs or customs) try: for txn_id, shipping in shippings: @@ -458,6 +460,11 @@ class ProviderStamps(models.Model): for i, url in enumerate(url_spaces, 1): response = urlopen(url) attachment = response.read() + # Stamps.com sends labels that set the print rate (print speed) to 8 Inches per Second + # this is too fast for international/customs forms that have fine detail + # set it to the general minimum of 2IPS + if had_customs: + attachment = attachment.replace(b'^PR8,8,8\r\n', b'^PR2\r\n') attachments.append(('LabelStamps-%s-%s.%s' % (label.TrackingNumber, i, self.stamps_image_type), attachment)) picking.message_post(body=body, attachments=attachments) shipping_data = {'exact_price': carrier_price, 'tracking_number': ','.join(tracking_numbers)}