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


Python Pool.search_using_magento_region方法代码示例

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


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

示例1: create_for_party_using_magento_data

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search_using_magento_region [as 别名]
    def create_for_party_using_magento_data(cls, party, address_data):
        """
        Create address from the address record given and link it to the
        party.

        :param party: Party active record
        :param address_data: Dictionary of address data from magento
        :return: Active record of created address
        """
        Country = Pool().get('country.country')
        Subdivision = Pool().get('country.subdivision')
        ContactMechanism = Pool().get('party.contact_mechanism')

        country = None
        subdivision = None
        if address_data['country_id']:
            country = Country.search_using_magento_code(
                address_data['country_id']
            )
            if address_data['region']:
                subdivision = Subdivision.search_using_magento_region(
                    address_data['region'], country
                )

        address, = cls.create([{
            'party': party.id,
            'name': ' '.join([
                address_data['firstname'], address_data['lastname']
            ]),
            'street': address_data['street'],
            'zip': address_data['postcode'],
            'city': address_data['city'],
            'country': country and country.id or None,
            'subdivision': subdivision and subdivision.id or None,
        }])

        # Create phone as contact mechanism
        if address_data.get('telephone') and not ContactMechanism.search([
            ('party', '=', party.id),
            ('type', 'in', ['phone', 'mobile']),
            ('value', '=', address_data['telephone']),
        ]):
            ContactMechanism.create([{
                'party': party.id,
                'type': 'phone',
                'value': address_data['telephone'],
            }])

        return address
开发者ID:prakashpp,项目名称:trytond-magento,代码行数:51,代码来源:party.py

示例2: create_for_party_using_magento_data

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search_using_magento_region [as 别名]
    def create_for_party_using_magento_data(cls, party, address_data):
        """
        Create address from the address record given and link it to the
        party.

        :param party: Party active record
        :param address_data: Dictionary of address data from magento
        :return: Active record of created address
        """
        Country = Pool().get("country.country")
        Subdivision = Pool().get("country.subdivision")
        ContactMechanism = Pool().get("party.contact_mechanism")

        country = None
        subdivision = None
        if address_data["country_id"]:
            country = Country.search_using_magento_code(address_data["country_id"])
            if address_data["region"]:
                subdivision = Subdivision.search_using_magento_region(address_data["region"], country)

        address, = cls.create(
            [
                {
                    "party": party.id,
                    "name": " ".join([address_data["firstname"], address_data["lastname"]]),
                    "street": address_data["street"],
                    "zip": address_data["postcode"],
                    "city": address_data["city"],
                    "country": country and country.id or None,
                    "subdivision": subdivision and subdivision.id or None,
                }
            ]
        )

        # Create phone as contact mechanism
        if address_data.get("telephone") and not ContactMechanism.search(
            [("party", "=", party.id), ("type", "in", ["phone", "mobile"]), ("value", "=", address_data["telephone"])]
        ):
            ContactMechanism.create([{"party": party.id, "type": "phone", "value": address_data["telephone"]}])

        return address
开发者ID:openlabs,项目名称:trytond-magento,代码行数:43,代码来源:party.py

示例3: match_with_magento_data

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search_using_magento_region [as 别名]
    def match_with_magento_data(self, address_data):
        """
        Match the current address with the address_record.
        Match all the fields of the address, i.e., streets, city, subdivision
        and country. For any deviation in any field, returns False.

        :param address_data: Dictionary of address data from magento
        :return: True if address matches else False
        """
        Country = Pool().get('country.country')
        Subdivision = Pool().get('country.subdivision')

        # Check if the name matches
        if self.name != ' '.join(
            [address_data['firstname'], address_data['lastname']]
        ):
            return False

        # Find country and subdivision based on magento data
        country = None
        subdivision = None
        if address_data['country_id']:
            country = Country.search_using_magento_code(
                address_data['country_id']
            )
            if address_data['region']:
                subdivision = Subdivision.search_using_magento_region(
                    address_data['region'], country
                )

        if not all([
            self.street == (address_data['street'] or None),
            self.zip == (address_data['postcode'] or None),
            self.city == (address_data['city'] or None),
            self.country == country,
            self.subdivision == subdivision,
        ]):
            return False

        return True
开发者ID:prakashpp,项目名称:trytond-magento,代码行数:42,代码来源:party.py


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