本文整理汇总了Python中ups.shipping_package.ShipmentConfirm.shipper_type方法的典型用法代码示例。如果您正苦于以下问题:Python ShipmentConfirm.shipper_type方法的具体用法?Python ShipmentConfirm.shipper_type怎么用?Python ShipmentConfirm.shipper_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ups.shipping_package.ShipmentConfirm
的用法示例。
在下文中一共展示了ShipmentConfirm.shipper_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_shipper
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipper_type [as 别名]
def get_shipper(shipper_number, country="GB"):
"""Returns a shipper from a known country"""
if country == "GB":
shipper_address = ShipmentConfirm.address_type(
AddressLine1="2,Hope Rd",
AddressLine2="Anson Road",
City="Manchester",
CountryCode="GB",
PostalCode="M145EU"
)
elif country == "US":
shipper_address = ShipmentConfirm.address_type(
AddressLine1="245 NE 24th Street",
AddressLine2="Suite 108",
City="Miami",
StateProvinceCode="FL",
CountryCode="US",
PostalCode="33137"
)
else:
raise Exception("This country is not supported")
return ShipmentConfirm.shipper_type(
shipper_address,
Name="Openlabs",
AttentionName="Openlabs",
TaxIdentificationNumber="33065",
PhoneNumber='0987654321',
ShipperNumber=shipper_number,
)
示例2: to_ups_shipper
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipper_type [as 别名]
def to_ups_shipper(self):
'''
Converts party address to UPS `Shipper Address`.
:return: Returns instance of ShipperAddress
'''
Company = Pool().get('company.company')
UPSConfiguration = Pool().get('ups.configuration')
vals = {}
if not self.party.phone:
self.raise_user_error(
"ups_field_missing",
error_args=('Phone no.', '"Shipper Address"')
)
company_id = Transaction().context.get('company')
if not company_id:
self.raise_user_error(
"ups_field_missing", error_args=('Company', 'context')
)
company_party = Company(company_id).party
vals = {
'CompanyName': company_party.name,
'TaxIdentificationNumber': company_party.vat_number,
'Name': self.name or self.party.name,
'AttentionName': self.name or self.party.name,
'PhoneNumber': digits_only_re.sub('', self.party.phone),
'ShipperNumber': UPSConfiguration(1).shipper_no,
}
fax = self.party.fax
if fax:
vals['FaxNumber'] = fax
# EMailAddress
email = self.party.email
if email:
vals['EMailAddress'] = email
return ShipmentConfirm.shipper_type(
self._get_ups_address_xml(),
**vals
)
示例3: get_shipper
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipper_type [as 别名]
def get_shipper(params):
if params:
doc = frappe.get_doc("Warehouse",params.get("default_warehouse"))
if not doc:
frappe.throw("Can not fetch shipper Address")
else:
return ShipmentConfirm.shipper_type(
# shipper_address,
UPSHelper.get_address(doc, True),
Name= params.get("user_name") or "",
AttentionName= params.get("attention_name") or "",
# TaxIdentificationNumber="33065",
PhoneNumber= doc.phone_no or "",
ShipperNumber= params.get("shipper_number") or "",
)
else:
frappe.throw("Shipper Address and Shipper Number fields required")
示例4: to_ups_shipper
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipper_type [as 别名]
def to_ups_shipper(self, carrier):
"""
Converts party address to UPS `Shipper Address`.
:return: Returns instance of ShipperAddress
"""
Company = Pool().get("company.company")
vals = {}
if not self.party.phone and not getattr(self, "phone"):
self.raise_user_error("ups_field_missing", error_args=("Phone no.", '"Shipper Address"'))
company_id = Transaction().context.get("company")
if not company_id:
self.raise_user_error("ups_field_missing", error_args=("Company", "context"))
company_party = Company(company_id).party
if getattr(self, "phone"):
phone = getattr(self, "phone")
else:
phone = self.party.phone
vals = {
"CompanyName": company_party.name,
"TaxIdentificationNumber": company_party.identifiers and company_party.identifiers[0].code or "",
"Name": self.name or self.party.name,
"AttentionName": self.name or self.party.name,
"PhoneNumber": digits_only_re.sub("", phone),
"ShipperNumber": carrier.ups_shipper_no,
}
fax = self.party.fax
if fax:
vals["FaxNumber"] = fax
# EMailAddress
email = self.party.email
if email:
vals["EMailAddress"] = email
return ShipmentConfirm.shipper_type(self._get_ups_address_xml(), **vals)