From 337e628ce7c164c2eef31d6f522f581521308c3c Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Wed, 4 Aug 2021 12:39:37 -0700 Subject: [PATCH] [IMP] delivery_stamps. International box weight must match sum of customs lines. --- delivery_stamps/models/delivery_stamps.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/delivery_stamps/models/delivery_stamps.py b/delivery_stamps/models/delivery_stamps.py index 37477410..c6d3a373 100644 --- a/delivery_stamps/models/delivery_stamps.py +++ b/delivery_stamps/models/delivery_stamps.py @@ -334,7 +334,11 @@ class ProviderStamps(models.Model): } product_values[quant.product_id]['quantity'] += quant.quantity product_values[quant.product_id]['value'] += quant.quantity * quant.product_id.lst_price - + + # Note that Stamps will not allow you to use the scale weight if it is not equal + # to the sum of the customs lines. + # Thus we sum the line + new_total_weight = 0.0 customs_lines = [] for product, values in product_values.items(): customs_line = service.create_customs_lines() @@ -342,13 +346,16 @@ class ProviderStamps(models.Model): customs_line.Quantity = values['quantity'] customs_total += round(values['value'], 2) customs_line.Value = round(values['value'], 2) - customs_line.WeightLb = self._stamps_convert_weight(product.weight * values['quantity']) + line_weight = round(self._stamps_convert_weight(product.weight * values['quantity']), 2) + customs_line.WeightLb = line_weight + new_total_weight += line_weight customs_line.HSTariffNumber = product.hs_code or '' # customs_line.CountryOfOrigin = customs_line.sku = product.default_code or '' customs_lines.append(customs_line) customs.CustomsLines.CustomsLine = customs_lines shipping.DeclaredValue = round(customs_total, 2) + shipping.WeightLb = round(new_total_weight, 2) label = service.get_label(shipping, transaction_id=txn_id, image_type=self.stamps_image_type,