本文整理汇总了Python中ups.shipping_package.ShipmentConfirm.packaging_type方法的典型用法代码示例。如果您正苦于以下问题:Python ShipmentConfirm.packaging_type方法的具体用法?Python ShipmentConfirm.packaging_type怎么用?Python ShipmentConfirm.packaging_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ups.shipping_package.ShipmentConfirm
的用法示例。
在下文中一共展示了ShipmentConfirm.packaging_type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_ups_packages
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import packaging_type [as 别名]
def _get_ups_packages(self):
"""
Return UPS Packages XML
"""
UPSConfiguration = Pool().get('ups.configuration')
ups_config = UPSConfiguration(1)
package_type = ShipmentConfirm.packaging_type(
Code=self.ups_package_type
) # FIXME: Support multiple packaging type
weight = self.package_weight.quantize(
Decimal('.01'), rounding=ROUND_UP
)
package_weight = ShipmentConfirm.package_weight_type(
Weight=str(weight),
Code=ups_config.weight_uom_code,
)
package_service_options = ShipmentConfirm.package_service_options_type(
ShipmentConfirm.insured_value_type(MonetaryValue='0')
)
package_container = ShipmentConfirm.package_type(
package_type,
package_weight,
package_service_options
)
return [package_container]
示例2: get_packages
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import packaging_type [as 别名]
def get_packages(packing_slips, package_type_code):
packages = []
for docname in packing_slips:
doc = frappe.get_doc("Packing Slip",docname)
# item = frappe.get_doc("Item", doc.package_used)
item = frappe.db.get_value("Custom UOM Conversion Details", {
"parent": doc.package_used,
"uom": "Nos"
}, ["length", "width", "height"], as_dict=True)
package_ref = "%s/%s"%(doc.delivery_note, doc.name)
package_weight = ShipmentConfirm.package_weight_type(
Weight= str(doc.gross_weight_pkg), Code="LBS", Description="Weight In Pounds")
dimensions = ShipmentConfirm.dimensions_type(
Code="IN",
Description="Deimensions In Inches",
Length= str(item.get("length")) or "0",
Width= str(item.get("width")) or "0",
Height= str(item.get("height")) or "0",
)
package_type = ShipmentConfirm.packaging_type(Code=package_type_code)
package = ShipmentConfirm.package_type(
package_type,
package_weight,
dimensions,
# E.ReferenceNumber(E.Value(package_ref)),
)
packages.append(package)
return packages
示例3: get_packages
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import packaging_type [as 别名]
def get_packages(packing_slips, package_type_code):
packages = []
for docname in packing_slips:
doc = frappe.get_doc("Packing Slip",docname)
item = frappe.get_doc("Item", doc.package_used)
package_ref = "%s/%s"%(doc.delivery_note, doc.name)
package_weight = ShipmentConfirm.package_weight_type(
Weight= str(doc.gross_weight_pkg), Code="LBS", Description="Weight In Pounds")
dimensions = ShipmentConfirm.dimensions_type(
Code="IN",
Description="Deimensions In Inches",
Length= str(item.length) or "0",
Width= str(item.width) or "0",
Height= str(item.height) or "0",
)
package_type = ShipmentConfirm.packaging_type(Code=package_type_code)
package = ShipmentConfirm.package_type(
package_type,
package_weight,
dimensions,
# E.ReferenceNumber(E.Value(package_ref)),
)
packages.append(package)
return packages
示例4: get_ups_package_container
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import packaging_type [as 别名]
def get_ups_package_container(self):
"""
Return UPS package container for a single package
"""
shipment = self.shipment
carrier = shipment.carrier
if self.box_type:
code = self.box_type.code
length = self.box_type.length
height = self.box_type.height
width = self.box_type.width
dimensions_symbol = self.box_type.distance_unit and \
self.box_type.distance_unit.symbol.upper()
else:
code = '02'
length = self.length
height = self.height
width = self.width
dimensions_symbol = self.distance_unit and \
self.distance_unit.symbol.upper()
package_type = ShipmentConfirm.packaging_type(Code=code)
package_weight = ShipmentConfirm.package_weight_type(
Weight="%.2f" % self.weight,
Code=carrier.ups_weight_uom_code,
)
package_service_options = ShipmentConfirm.package_service_options_type(
ShipmentConfirm.insured_value_type(MonetaryValue='0')
)
args = [package_type, package_weight, package_service_options]
# Only send dimensions if the box type is 'Customer Supplied Package'
if code == '02' and length and width and height and dimensions_symbol:
package_dimensions = ShipmentConfirm.dimensions_type(
Code=dimensions_symbol,
Length=str(length),
Width=str(width),
Height=str(height)
)
args.append(package_dimensions)
package_container = ShipmentConfirm.package_type(*args)
return package_container
示例5: get_package
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import packaging_type [as 别名]
def get_package(
country="GB", package_type_code='02', weight='14.1', dimensions=None
):
"""UPS really expects units that are used in the country
:param package_type_code: Str of the Code
:param weight: Str eg '14.1'
:param dimensions: A dict with length, width and height
eg {'length': 10, 'width': 10, 'height': 10}
"""
if dimensions is None:
dimensions = {
'length': '10',
'width': '10',
'height': '10',
}
if country == "GB":
package_weight = ShipmentConfirm.package_weight_type(
Weight=weight, Code="KGS", Description="Kilograms")
dimensions = ShipmentConfirm.dimensions_type(
Code="CM",
Length=dimensions['length'],
Width=dimensions['width'],
Height=dimensions['height'],
)
elif country == "US":
package_weight = ShipmentConfirm.package_weight_type(
Weight=weight, Code="LBS", Description="Pounds")
dimensions = ShipmentConfirm.dimensions_type(
Code="IN",
Length=dimensions['length'],
Width=dimensions['width'],
Height=dimensions['height'],
)
else:
raise Exception("This country is not supported")
package_type = ShipmentConfirm.packaging_type(Code=package_type_code)
return ShipmentConfirm.package_type(
package_type,
package_weight,
dimensions,
)
示例6: get_ups_package_container
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import packaging_type [as 别名]
def get_ups_package_container(self):
"""
Return UPS package container for a single package
"""
shipment = self.shipment
carrier = shipment.carrier
package_type = ShipmentConfirm.packaging_type(
Code=shipment.ups_package_type
) # FIXME: Support multiple packaging type
package_weight = ShipmentConfirm.package_weight_type(
Weight="%.2f" % self.weight, Code=carrier.ups_weight_uom_code
)
package_service_options = ShipmentConfirm.package_service_options_type(
ShipmentConfirm.insured_value_type(MonetaryValue="0")
)
package_container = ShipmentConfirm.package_type(package_type, package_weight, package_service_options)
return package_container