Do not fill Dimensions not PackageWeight when value is None

issue10627
review349041002
(grafted from fa8aec1bfa876edd0e328252ec916261332dc27d)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2021-08-12 18:41:49 +02:00
1 parent c9098eb77a
commit 015e13064a
1 file changed
+11 -6
+11 -6
View File
@@ -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(