コード例 #1
0
ファイル: stock.py プロジェクト: mbehrle/trytond-shipping-ups
    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
0
    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]
コード例 #3
0
    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
コード例 #4
0
    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
コード例 #5
0
ファイル: stock.py プロジェクト: nicoe/trytond-shipping-ups
    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