diff --git a/stock.py b/stock.py index 1235110b65..f46b238e39 100644 --- a/stock.py +++ b/stock.py @@ -311,11 +311,15 @@ class CreateShippingUPS(Wizard): 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 @@ class CreateShippingUPS(Wizard): 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(