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


Python StockTransaction.get_ordered_transactions_for_stock方法代码示例

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


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

示例1: recalculate_domain_consumption

# 需要导入模块: from casexml.apps.stock.models import StockTransaction [as 别名]
# 或者: from casexml.apps.stock.models.StockTransaction import get_ordered_transactions_for_stock [as 别名]
def recalculate_domain_consumption(domain):
    """
    Given a domain, recalculate all saved consumption settings in that domain.
    """
    # note: might get slow as this gets huge
    found_doc_ids = DocDomainMapping.objects.filter(
        domain_name=domain,
        doc_type='CommCareCase',
    ).values_list('doc_id', flat=True)
    products = Product.by_domain(domain)
    for supply_point_id in found_doc_ids:
        for product in products:
            filtered_transactions = StockTransaction.get_ordered_transactions_for_stock(
                supply_point_id, const.SECTION_TYPE_STOCK, product._id
            )
            if filtered_transactions:
                update_stock_state_for_transaction(filtered_transactions[0])
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:19,代码来源:consumption.py

示例2: recalculate_domain_consumption

# 需要导入模块: from casexml.apps.stock.models import StockTransaction [as 别名]
# 或者: from casexml.apps.stock.models.StockTransaction import get_ordered_transactions_for_stock [as 别名]
def recalculate_domain_consumption(domain):
    """
    Given a domain, recalculate all saved consumption settings in that domain.
    """
    # note: might get slow as this gets huge
    found_doc_ids = DocDomainMapping.objects.filter(
        domain_name=domain,
        doc_type='CommCareCase',
    ).values_list('doc_id', flat=True)
    products = Product.by_domain(domain)
    for supply_point_id in found_doc_ids:
        for product in products:
            try:
                latest_transaction = StockTransaction.get_ordered_transactions_for_stock(
                    supply_point_id, const.SECTION_TYPE_STOCK, product._id
                )[0]
            except IndexError:
                pass
            else:
                state = get_stock_state_for_transaction(latest_transaction)
                daily_consumption = get_consumption_for_ledger(state)
                state.daily_consumption = daily_consumption
                with drop_connected_signals(post_save):
                    state.save()
开发者ID:dimagi,项目名称:commcare-hq,代码行数:26,代码来源:consumption.py

示例3: _get_stats

# 需要导入模块: from casexml.apps.stock.models import StockTransaction [as 别名]
# 或者: from casexml.apps.stock.models.StockTransaction import get_ordered_transactions_for_stock [as 别名]
 def _get_stats(self):
     stock_state = StockState.objects.get(**self._stock_state_key)
     latest_txn = StockTransaction.latest(**self._stock_state_key)
     all_txns = StockTransaction.get_ordered_transactions_for_stock(
         **self._stock_state_key)
     return stock_state, latest_txn, all_txns
开发者ID:nnestle,项目名称:commcare-hq,代码行数:8,代码来源:test_rebuild.py


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