Ejemplo n.º 1
0
    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',
        )
Ejemplo n.º 2
0
    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',
        )
    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 "",
            )
    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 "",
            )
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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)