changeset 614bb3d4a0b7 in modules/stock_package_shipping_ups:5.0
details:
https://hg.tryton.org/modules/stock_package_shipping_ups?cmd=changeset&node=614bb3d4a0b7
description:
Do not fill Dimensions not PackageWeight when value is None
issue10627
review349041002
(grafted from fa8aec1bfa876edd0e328252ec916261332dc27d)
diffstat:
stock.py | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diffs (42 lines):
diff -r 781eebe47644 -r 614bb3d4a0b7 stock.py
--- a/stock.py Thu Jul 01 21:43:36 2021 +0200
+++ b/stock.py Thu Aug 12 18:41:49 2021 +0200
@@ -285,11 +285,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.type.length is not None
+ and package.type.width is not None
+ and package.type.height is not None):
+ pkg['Dimensions'] = {
'UnitOfMeasurement': {
'Code': 'CM' if use_metric else 'IN',
},
@@ -299,15 +303,16 @@
package.type.width, cm if use_metric else inch)),
'Height': '%i' % round(UoM.compute_qty(package.type.height_uom,
package.type.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):
warehouse_address = shipment.warehouse.address