本文整理汇总了Python中ups.shipping_package.ShipmentConfirm.ship_from_type方法的典型用法代码示例。如果您正苦于以下问题:Python ShipmentConfirm.ship_from_type方法的具体用法?Python ShipmentConfirm.ship_from_type怎么用?Python ShipmentConfirm.ship_from_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ups.shipping_package.ShipmentConfirm
的用法示例。
在下文中一共展示了ShipmentConfirm.ship_from_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_ship_from
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import ship_from_type [as 别名]
def get_ship_from(country="GB"):
"""Returns a shipfrom from a known country"""
if country == "GB":
ship_from_address = ShipmentConfirm.address_type(
AddressLine1="2,Hope Rd",
AddressLine2="Anson Road",
City="Manchester",
CountryCode="GB",
PostalCode="M145EU"
)
elif country == "US":
ship_from_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.ship_from_type(
ship_from_address,
CompanyName="Openlabs",
AttentionName="Someone other than Sharoon",
TaxIdentificationNumber="33065",
PhoneNumber='0987654321',
)
示例2: get_ship_from_address
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import ship_from_type [as 别名]
def get_ship_from_address(params, address_name):
doc = frappe.get_doc("Warehouse",address_name)
if not doc:
frappe.throw("Can not fetch Shipper Address")
else:
ship_from_address = UPSHelper.get_address(doc,True)
return ShipmentConfirm.ship_from_type(
ship_from_address,
CompanyName= params.get("attention_name") or "",
AttentionName= params.get("user_name") or "",
# TaxIdentificationNumber="",
PhoneNumber= doc.phone_no or "",
)
示例3: to_ups_from_address
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import ship_from_type [as 别名]
def to_ups_from_address(self):
'''
Converts party address to UPS `From Address`.
:return: Returns instance of FromAddress
'''
Company = Pool().get('company.company')
vals = {}
if not self.party.phone:
self.raise_user_error(
"ups_field_missing",
error_args=('Phone no.', '"from 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,
'AttentionName': self.name or self.party.name,
'TaxIdentificationNumber': company_party.vat_number,
'PhoneNumber': digits_only_re.sub('', self.party.phone),
}
fax = self.party.fax
if fax:
vals['FaxNumber'] = fax
# EMailAddress
email = self.party.email
if email:
vals['EMailAddress'] = email
return ShipmentConfirm.ship_from_type(
self._get_ups_address_xml(), **vals)
示例4: to_ups_from_address
# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import ship_from_type [as 别名]
def to_ups_from_address(self):
"""
Converts party address to UPS `From Address`.
:return: Returns instance of FromAddress
"""
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.", '"from 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,
"AttentionName": self.name or self.party.name,
"TaxIdentificationNumber": company_party.identifiers and company_party.identifiers[0].code or "",
"PhoneNumber": digits_only_re.sub("", phone),
}
fax = self.party.fax
if fax:
vals["FaxNumber"] = fax
# EMailAddress
email = self.party.email
if email:
vals["EMailAddress"] = email
return ShipmentConfirm.ship_from_type(self._get_ups_address_xml(), **vals)