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


Python Pool.create_using_amazon_data方法代码示例

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


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

示例1: import_product

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create_using_amazon_data [as 别名]
    def import_product(self, sku):
        """
        Import specific product for this amazon channel
        Downstream implementation for channel.import_product

        :param sku: Product Seller SKU from Amazon
        :returns: Active record of Product Created
        """
        Product = Pool().get('product.product')

        if self.source != 'amazon_mws':
            return super(SaleChannel, self).import_product(sku)

        products = Product.search([('code', '=', sku)])

        if products:
            return products[0]

        # If product is not found get the info from amazon and
        # delegate to create_using_amazon_data

        product_api = self.get_amazon_product_api()

        product_data = product_api.get_matching_product_for_id(
            self.amazon_marketplace_id, 'SellerSKU', [sku]
        ).parsed

        return Product.create_using_amazon_data(product_data)
开发者ID:sharoonthomas,项目名称:trytond-amazon-mws,代码行数:30,代码来源:channel.py

示例2: import_order

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create_using_amazon_data [as 别名]
    def import_order(self, order_id):
        "Downstream implementation of channel.import_order from sale channel"
        if self.source != 'amazon_mws':
            return super(SaleChannel, self).import_order(order_id)

        Sale = Pool().get('sale.sale')

        sales = Sale.search([
            ('amazon_order_id', '=', order_id),
        ])
        if sales:
            return sales[0]

        order_api = self.get_amazon_order_api()

        order_data = order_api.get_order([order_id]).parsed

        order_line_data = order_api.list_order_items(
            order_data['Orders']['Order']['AmazonOrderId']['value']
        ).parsed

        with Transaction().set_context({'current_channel': self.id}):
            return Sale.create_using_amazon_data(
                order_data['Orders']['Order'],
                order_line_data['OrderItems']['OrderItem']
            )
开发者ID:yanggg1133,项目名称:trytond-amazon-mws,代码行数:28,代码来源:channel.py

示例3: import_order_bulk

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create_using_amazon_data [as 别名]
    def import_order_bulk(self, amazon_order_ids):
        """
        It is expensive to get orders one by one and in addition, it will
        throttle the API requests.
        """
        Sale = Pool().get('sale.sale')

        sales = []
        order_api = self.get_amazon_order_api()

        for order_ids_batch in batch(amazon_order_ids, 50):
            # The order fetch API limits getting orders to a maximum
            # of 50 at a time
            try:
                orders_data = order_api.get_order(order_ids_batch).parsed
            except mws.MWSError, e:
                # Do not continue further in this method as further calls
                # to amazon will raise same error for further calls,
                # but calling return will let imported orders commit to
                # database. Else this will become a never ending process.
                logger.warning(e.message)
                return sales

            orders = orders_data['Orders']['Order']
            if not isinstance(orders, list):
                orders = [orders]

            for order in orders:
                already_imported = Sale.search([
                    ('channel', '=', self.id),
                    (
                        'channel_identifier', '=',
                        order['AmazonOrderId']['value']
                    ),
                ])
                if not already_imported:
                    # New order! get the line items and save the order.
                    order_line_data = order_api.list_order_items(
                        order['AmazonOrderId']['value']
                    ).parsed

                    with Transaction().set_context(
                        {'current_channel': self.id}
                    ):
                        sales.append(
                            Sale.create_using_amazon_data(
                                order,
                                order_line_data['OrderItems']['OrderItem']
                            )
                        )
                else:
                    # Order is already there, just ensure it is in the
                    # right status
                    already_imported[0].update_order_status_from_amazon_mws(
                        order
                    )
开发者ID:riteshshrv,项目名称:trytond-amazon-mws_old,代码行数:58,代码来源:channel.py

示例4: import_mws_order_bulk

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create_using_amazon_data [as 别名]
    def import_mws_order_bulk(self, amazon_orders_data):
        """
        It is expensive to get orders one by one and in addition, it will
        throttle the API requests.
        """
        Sale = Pool().get('sale.sale')

        sales = []
        order_api = self.get_amazon_order_api()

        for order in amazon_orders_data:
            already_imported = Sale.search([
                ('channel', '=', self.id),
                (
                    'channel_identifier', '=',
                    order['AmazonOrderId']['value']
                ),
            ])
            if not already_imported:
                # New order! get the line items and save the order.
                order_line_data = order_api.list_order_items(
                    order['AmazonOrderId']['value']
                ).parsed

                with Transaction().set_context(
                    {'current_channel': self.id}
                ):
                    sales.append(
                        Sale.create_using_amazon_data(
                            order,
                            order_line_data['OrderItems']['OrderItem']
                        )
                    )
            else:
                # Order is already there, just ensure it is in the
                # right status
                sales.append(already_imported[0])
                already_imported[0].update_order_status_from_amazon_mws(
                    order
                )
        return sales
开发者ID:Jason-Kou,项目名称:trytond-amazon-mws,代码行数:43,代码来源:channel.py


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