From 015e13064a5ca98755387e4abaedbf60874cff00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 12 Aug 2021 18:41:49 +0200 Subject: [PATCH] Do not fill Dimensions not PackageWeight when value is None issue10627 review349041002 (grafted from fa8aec1bfa876edd0e328252ec916261332dc27d) --HG-- branch : 6.0 --- stock.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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(