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


Python ProductHistory.add_produced_item方法代码示例

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


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

示例1: produce

# 需要导入模块: from stoqlib.domain.product import ProductHistory [as 别名]
# 或者: from stoqlib.domain.product.ProductHistory import add_produced_item [as 别名]
    def produce(self, quantity, produced_by=None, serials=None):
        """Sets a certain quantity as produced. The quantity will be marked as
        produced only if there are enough materials allocated, otherwise a
        ValueError exception will be raised.

        :param quantity: the quantity that will be produced.
        """
        assert self.can_produce(quantity)

        # check if its ok to produce before consuming material
        if self.product.has_quality_tests():
            # We have some quality tests to assure. Register it for later
            assert produced_by
            assert len(serials) == quantity
            # We only support yield quantity > 1 when there are no tests
            assert self.product.yield_quantity == 1

        self.store.savepoint(u'before_produce')

        for component in self.get_components():
            material = self._get_material_from_component(component)
            needed_material = quantity * component.quantity

            try:
                material.consume(needed_material)
            except ValueError:
                self.store.rollback_to_savepoint(u'before_produce')
                raise

        if self.product.has_quality_tests():
            for serial in serials:
                ProductionProducedItem(store=self.store,
                                       order=self.order,
                                       product=self.product,
                                       produced_by=produced_by,
                                       produced_date=localnow(),
                                       serial_number=serial,
                                       entered_stock=False)
        else:
            # There are no quality tests for this product. Increase stock
            # right now.
            storable = self.product.storable
            # A production process may yield more than one unit of this product
            yield_quantity = quantity * self.product.yield_quantity
            storable.increase_stock(yield_quantity, self.order.branch,
                                    StockTransactionHistory.TYPE_PRODUCTION_PRODUCED,
                                    self.id)
        self.produced += quantity
        self.order.try_finalize_production()
        ProductHistory.add_produced_item(self.store, self.order.branch, self)
开发者ID:hackedbellini,项目名称:stoq,代码行数:52,代码来源:production.py


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