当前位置: 首页>>代码示例>>Python>>正文


Python ShipmentConfirm.shipment_confirm_request_type方法代码示例

本文整理汇总了Python中ups.shipping_package.ShipmentConfirm.shipment_confirm_request_type方法的典型用法代码示例。如果您正苦于以下问题:Python ShipmentConfirm.shipment_confirm_request_type方法的具体用法?Python ShipmentConfirm.shipment_confirm_request_type怎么用?Python ShipmentConfirm.shipment_confirm_request_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ups.shipping_package.ShipmentConfirm的用法示例。


在下文中一共展示了ShipmentConfirm.shipment_confirm_request_type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_shipment_confirm_xml

# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipment_confirm_request_type [as 别名]
    def _get_shipment_confirm_xml(self):
        """
        Return XML of shipment for shipment_confirm
        """
        Company = Pool().get('company.company')
        UPSConfiguration = Pool().get('ups.configuration')

        ups_config = UPSConfiguration(1)
        if not self.ups_service_type:
            self.raise_user_error('ups_service_type_missing')

        payment_info_prepaid = \
            ShipmentConfirm.payment_information_prepaid_type(
                AccountNumber=ups_config.shipper_no
            )
        payment_info = ShipmentConfirm.payment_information_type(
            payment_info_prepaid)
        packages = self._get_ups_packages()
        shipment_service = ShipmentConfirm.shipment_service_option_type(
            SaturdayDelivery='1' if self.ups_saturday_delivery
            else 'None'
        )
        description = ','.join([
            move.product.name for move in self.outgoing_moves
        ])

        shipment_args = [
            self.warehouse.address.to_ups_shipper(),
            self.delivery_address.to_ups_to_address(),
            self.warehouse.address.to_ups_from_address(),
            ShipmentConfirm.service_type(Code=self.ups_service_type.code),
            payment_info, shipment_service,
        ]
        if ups_config.negotiated_rates:
            shipment_args.append(
                ShipmentConfirm.rate_information_type(negotiated=True)
            )
        if self.warehouse.address.country.code == 'US' and \
                self.delivery_address.country.code in ['PR', 'CA']:
            # Special case for US to PR or CA InvoiceLineTotal should be sent
            monetary_value = str(sum(map(
                lambda move: move.get_monetary_value_for_ups(),
                self.outgoing_moves
            )))

            company_id = Transaction().context.get('company')
            if not company_id:
                self.raise_user_error("Company is not in context")

            company = Company(company_id)
            shipment_args.append(ShipmentConfirm.invoice_line_total_type(
                MonetaryValue=monetary_value,
                CurrencyCode=company.currency.code
            ))

        shipment_args.extend(packages)
        shipment_confirm = ShipmentConfirm.shipment_confirm_request_type(
            *shipment_args, Description=description[:35]
        )
        return shipment_confirm
开发者ID:mbehrle,项目名称:trytond-shipping-ups,代码行数:62,代码来源:stock.py

示例2: test_0020_gb_gb

# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipment_confirm_request_type [as 别名]
    def test_0020_gb_gb(self):
        "GB to GB UPS Standard with 2 packages"
        ship_confirm_request = ShipmentConfirm.shipment_confirm_request_type(
            Helper.get_shipper(self.shipper_number, "GB"),
            Helper.get_ship_to("GB"),
            Helper.get_ship_from("GB"),

            # Package 1
            Helper.get_package(
                "GB", weight='15.0', package_type_code='02'
            ),  # Customer Supplied Package

            # Package 2
            Helper.get_package(
                "GB", weight='15.0', package_type_code='02'
            ),  # Customer Supplied Package

            Helper.get_payment_info(AccountNumber=self.shipper_number),
            ShipmentConfirm.service_type(Code='11'),    # UPS Standard
            Description=__doc__[:50]
        )
        response = self.shipment_confirm_api.request(ship_confirm_request)
        digest = self.shipment_confirm_api.extract_digest(response)

        # now accept the package
        accept_request = ShipmentAccept.shipment_accept_request_type(digest)
        self.shipment_accept_api.request(accept_request)
开发者ID:sharoonthomas,项目名称:PyUPS,代码行数:29,代码来源:test_shipping_package_gb_xx.py

示例3: test_0010_blow_up

# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipment_confirm_request_type [as 别名]
 def test_0010_blow_up(self):
     """Send a stupid request which should blow up because its valid in the
     client but not in UPS server. Example: dont send packages"""
     with self.assertRaises(PyUPSException):
         ship_confirm_request = ShipmentConfirm.shipment_confirm_request_type(
             Helper.get_shipper(self.shipper_number, "GB"),
             Helper.get_ship_to("GB"),
             Helper.get_ship_from("GB"),
             Helper.get_payment_info(AccountNumber=self.shipper_number),
             ShipmentConfirm.service_type(Code="11"),  # UPS Standard
             Description=__doc__[:50],
         )
         self.shipment_confirm_api.request(ship_confirm_request)
开发者ID:openlabs,项目名称:PyUPS,代码行数:15,代码来源:test_shipping_package_gb_xx.py

示例4: _get_shipment_confirm_xml

# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipment_confirm_request_type [as 别名]
    def _get_shipment_confirm_xml(self):
        """
        Return XML of shipment for shipment_confirm
        """
        Company = Pool().get("company.company")

        carrier = self.carrier
        if not self.ups_service_type:
            self.raise_user_error("ups_service_type_missing")

        payment_info_prepaid = ShipmentConfirm.payment_information_prepaid_type(AccountNumber=carrier.ups_shipper_no)
        payment_info = ShipmentConfirm.payment_information_type(payment_info_prepaid)
        packages = self._get_ups_packages()
        shipment_service = ShipmentConfirm.shipment_service_option_type(
            SaturdayDelivery="1" if self.ups_saturday_delivery else "None"
        )
        description = ",".join([move.product.name for move in self.outgoing_moves])
        from_address = self._get_ship_from_address()

        shipment_args = [
            from_address.to_ups_shipper(carrier=carrier),
            self.delivery_address.to_ups_to_address(),
            from_address.to_ups_from_address(),
            ShipmentConfirm.service_type(Code=self.ups_service_type.code),
            payment_info,
            shipment_service,
        ]
        if carrier.ups_negotiated_rates:
            shipment_args.append(ShipmentConfirm.rate_information_type(negotiated=True))
        if from_address.country.code == "US" and self.delivery_address.country.code in ["PR", "CA"]:
            # Special case for US to PR or CA InvoiceLineTotal should be sent
            monetary_value = str(sum(map(lambda move: move.get_monetary_value_for_ups(), self.outgoing_moves)))

            company_id = Transaction().context.get("company")
            if not company_id:
                self.raise_user_error("Company is not in context")

            company = Company(company_id)
            shipment_args.append(
                ShipmentConfirm.invoice_line_total_type(
                    MonetaryValue=monetary_value, CurrencyCode=company.currency.code
                )
            )

        shipment_args.extend(packages)
        shipment_confirm = ShipmentConfirm.shipment_confirm_request_type(*shipment_args, Description=description[:35])
        return shipment_confirm
开发者ID:riteshshrv,项目名称:trytond-shipping-ups,代码行数:49,代码来源:stock.py

示例5: test_0030_gb_gb_saturday

# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipment_confirm_request_type [as 别名]
    def test_0030_gb_gb_saturday(self):
        "GB to GB UPS Standard with 2 packages and Saturday delivery"
        ship_confirm_request = ShipmentConfirm.shipment_confirm_request_type(
            Helper.get_shipper(self.shipper_number, "GB"),
            Helper.get_ship_to("GB"),
            Helper.get_ship_from("GB"),
            # Package 1
            Helper.get_package("GB", weight="15.0", package_type_code="02"),  # Customer Supplied Package
            # Package 2
            Helper.get_package("GB", weight="15.0", package_type_code="02"),  # Customer Supplied Package
            ShipmentConfirm.shipment_service_option_type(SaturdayDelivery="1"),
            Helper.get_payment_info(AccountNumber=self.shipper_number),
            ShipmentConfirm.service_type(Code="11"),  # UPS Standard
            Description=__doc__[:50],
        )
        response = self.shipment_confirm_api.request(ship_confirm_request)
        digest = self.shipment_confirm_api.extract_digest(response)

        # now accept the package
        accept_request = ShipmentAccept.shipment_accept_request_type(digest)
        self.shipment_accept_api.request(accept_request)
开发者ID:openlabs,项目名称:PyUPS,代码行数:23,代码来源:test_shipping_package_gb_xx.py

示例6: get_ups_shipment_confirm_request

# 需要导入模块: from ups.shipping_package import ShipmentConfirm [as 别名]
# 或者: from ups.shipping_package.ShipmentConfirm import shipment_confirm_request_type [as 别名]
def get_ups_shipment_confirm_request(delivery_note, params):
    dn = delivery_note
    packing_slips = [row.packing_slip for row in dn.packing_slip_details]
    if not packing_slips:
        frappe.throw("Can not find the linked Packing Slip ...")

    ship_from_address_name = params.get("default_warehouse")
    shipper_number = params.get("shipper_number")
    package_type = ups_packages.get(params.get("package_type"))
    rates = {}
    if dn.ups_rates:
        rates = json.loads(dn.ups_rates)
    service_code = rates.get("service_used") or "03"
    ship_to_params = {
        "customer":dn.customer,
        "contact_display":dn.contact_display,
        "contact_mobile":dn.contact_mobile
    }

    packages = Helper.get_packages(packing_slips, package_type)

    request = ShipmentConfirm.shipment_confirm_request_type(
        Helper.get_shipper(params),
        Helper.get_ship_to_address(ship_to_params, dn.shipping_address_name,),
        Helper.get_ship_from_address(params, ship_from_address_name),
        Helper.get_payment_info(AccountNumber=shipper_number),
        ShipmentConfirm.service_type(Code=service_code),
        # Labal specification container
        LabelSpecification = E.LabelSpecification(
            E.LabelPrintMethod(E.Code("ZPL"),),
            E.LabelStockSize(E.Height("4"),E.Width("6"),),
            E.LabelImageFormat(E.Code("ZPL"),),
        ),
        Description="Description"
    )
    request.find("Shipment").extend(packages)

    return request
开发者ID:mbauskar,项目名称:alec_frappe_subscription,代码行数:40,代码来源:ups_shipping_package.py


注:本文中的ups.shipping_package.ShipmentConfirm.shipment_confirm_request_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。