Round up the measurements for package shipping APIs
Closes #13494 (grafted from 34b17e6b28bd0bccdfb5b6576e29ee4a50cad3bc) --HG-- branch : 6.0
This commit is contained in:
1 parent
de4f99d8be
commit
01cfe12df8
2 files changed
+24
-14
No files matched your search
@@ -4,6 +4,7 @@
|
||||
import locale
|
||||
from io import BytesIO
|
||||
from itertools import zip_longest
|
||||
from math import ceil
|
||||
|
||||
from lxml import etree
|
||||
from zeep.exceptions import Fault
|
||||
@@ -262,12 +263,12 @@ class CreateDPDShipping(Wizard):
|
||||
if (package.length is not None
|
||||
and package.width is not None
|
||||
and package.height is not None):
|
||||
length = UoM.compute_qty(
|
||||
package.length_uom, package.length, cm)
|
||||
width = UoM.compute_qty(
|
||||
package.width_uom, package.width, cm)
|
||||
height = UoM.compute_qty(
|
||||
package.height_uom, package.height, cm)
|
||||
length = ceil(UoM.compute_qty(
|
||||
package.length_uom, package.length, cm, round=False))
|
||||
width = ceil(UoM.compute_qty(
|
||||
package.width_uom, package.width, cm, round=False))
|
||||
height = ceil(UoM.compute_qty(
|
||||
package.height_uom, package.height, cm, round=False))
|
||||
if length < 1000 and width < 1000 and height < 1000:
|
||||
parcel['volume'] = int(
|
||||
'%03i%03i%03i' % (length, width, height))
|
||||
|
||||
@@ -7,6 +7,7 @@ import requests
|
||||
import ssl
|
||||
import urllib.parse
|
||||
from itertools import zip_longest
|
||||
from math import ceil
|
||||
|
||||
from trytond.config import config
|
||||
from trytond.i18n import gettext
|
||||
@@ -327,20 +328,28 @@ class CreateShippingUPS(Wizard):
|
||||
'UnitOfMeasurement': {
|
||||
'Code': 'CM' if use_metric else 'IN',
|
||||
},
|
||||
'Length': '%i' % round(UoM.compute_qty(package.length_uom,
|
||||
package.length, cm if use_metric else inch)),
|
||||
'Width': '%i' % round(UoM.compute_qty(package.width_uom,
|
||||
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)),
|
||||
'Length': '%i' % ceil(
|
||||
UoM.compute_qty(
|
||||
package.length_uom, package.length,
|
||||
cm if use_metric else inch, round=False)),
|
||||
'Width': '%i' % ceil(
|
||||
UoM.compute_qty(
|
||||
package.width_uom, package.width,
|
||||
cm if use_metric else inch, round=False)),
|
||||
'Height': '%i' % ceil(
|
||||
UoM.compute_qty(
|
||||
package.height_uom, package.height,
|
||||
cm if use_metric else inch, round=False)),
|
||||
}
|
||||
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)),
|
||||
'Weight': '%i' % ceil(
|
||||
UoM.compute_qty(
|
||||
kg, package.total_weight,
|
||||
kg if use_metric else lb, round=False)),
|
||||
}
|
||||
return pkg
|
||||
|
||||
|
||||
Reference in new issue
Block a user