コード例 #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_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
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]
コード例 #4
0
    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
コード例 #5
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
コード例 #6
0
    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,
        )
コード例 #7
0
ファイル: helper.py プロジェクト: openlabs/PyUPS
    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,
        )
コード例 #8
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
コード例 #9
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
コード例 #10
0
    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