changeset fa8aec1bfa87 in modules/stock_package_shipping_ups:default
details: 
https://hg.tryton.org/modules/stock_package_shipping_ups?cmd=changeset&node=fa8aec1bfa87
description:
        Do not fill Dimensions not PackageWeight when value is None

        issue10627
        review349041002
diffstat:

 stock.py |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r e3f39d3fbca2 -r fa8aec1bfa87 stock.py
--- a/stock.py  Sun Jul 04 17:54:48 2021 +0200
+++ b/stock.py  Thu Aug 12 18:41:49 2021 +0200
@@ -311,11 +311,15 @@
         kg = UoM(ModelData.get_id('product', 'uom_kilogram'))
         lb = UoM(ModelData.get_id('product', 'uom_pound'))
 
-        return {
+        pkg = {
             'Packaging': {
                 'Code': package.type.ups_code,
                 },
-            'Dimensions': {
+            }
+        if (package.length is not None
+                and package.width is not None
+                and package.height is not None):
+            pkg['Dimensions'] = {
                 'UnitOfMeasurement': {
                     'Code': 'CM' if use_metric else 'IN',
                     },
@@ -325,15 +329,16 @@
                         package.width, cm if use_metric else inch)),
                 'Height': '%i' % round(UoM.compute_qty(package.height_uom,
                         package.height, cm if use_metric else inch)),
-                },
-            'PackageWeight': {
+                }
+        if package.total_weight is not None:
+            pkg['PackageWeight'] = {
                 'UnitOfMeasurement': {
                     'Code': 'KGS' if use_metric else 'LBS',
                     },
                 'Weight': str(UoM.compute_qty(kg, package.total_weight,
                         kg if use_metric else lb)),
-                },
-            }
+                }
+        return pkg
 
     def get_request(self, shipment, packages, credential):
         shipper = self.get_shipping_party(

Reply via email to