本文整理汇总了Python中stoqlib.domain.product.ProductHistory类的典型用法代码示例。如果您正苦于以下问题:Python ProductHistory类的具体用法?Python ProductHistory怎么用?Python ProductHistory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductHistory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_stock_items
def add_stock_items(self):
"""This is normally called from ReceivingOrder when
a the receving order is confirmed.
"""
store = self.store
if self.quantity > self.get_remaining_quantity():
raise ValueError(
u"Quantity received (%d) is greater than "
u"quantity ordered (%d)" % (self.quantity, self.get_remaining_quantity())
)
branch = self.receiving_order.branch
storable = self.sellable.product_storable
purchase = self.purchase_item.order
if storable is not None:
storable.increase_stock(
self.quantity,
branch,
StockTransactionHistory.TYPE_RECEIVED_PURCHASE,
self.id,
self.cost,
batch=self.batch,
)
purchase.increase_quantity_received(self.purchase_item, self.quantity)
ProductHistory.add_received_item(store, branch, self)
开发者ID:amaurihamasu,项目名称:stoq,代码行数:25,代码来源:receiving.py
示例2: confirm
def confirm(self):
"""Confirms the stock decrease
"""
assert self.can_confirm()
assert self.branch
store = self.store
branch = self.branch
for item in self.get_items():
if item.sellable.product:
ProductHistory.add_decreased_item(store, branch, item)
item.decrease(branch)
old_status = self.status
self.status = StockDecrease.STATUS_CONFIRMED
# Save the operation_nature and branch in Invoice Table
self.invoice.operation_nature = self.operation_nature
self.invoice.branch = branch
if self.group:
self.group.confirm()
StockOperationConfirmedEvent.emit(self, old_status)
开发者ID:stoq,项目名称:stoq,代码行数:25,代码来源:stockdecrease.py
示例3: send
def send(self):
"""Sends this item to it's destination |branch|"""
assert self.transfer_order.can_close()
storable = self.sellable.product_storable
storable.decrease_stock(self.quantity, self.transfer_order.source_branch,
StockTransactionHistory.TYPE_TRANSFER_TO,
self.id)
ProductHistory.add_transfered_item(self.store, self.transfer_order.source_branch, self)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:9,代码来源:transfer.py
示例4: send_item
def send_item(self, transfer_item):
"""Sends a |product| of this order to it's destination |branch|"""
assert self.can_close()
storable = transfer_item.sellable.product_storable
storable.decrease_stock(transfer_item.quantity, self.source_branch,
StockTransactionHistory.TYPE_TRANSFER_TO,
transfer_item.id)
store = self.store
ProductHistory.add_transfered_item(store, self.source_branch,
transfer_item)
开发者ID:romaia,项目名称:stoq,代码行数:11,代码来源:transfer.py
示例5: send
def send(self):
"""Sends this item to it's destination |branch|.
This method should never be used directly, and to send a transfer you
should use TransferOrder.send().
"""
storable = self.sellable.product_storable
storable.decrease_stock(self.quantity,
self.transfer_order.source_branch,
StockTransactionHistory.TYPE_TRANSFER_TO,
self.id, batch=self.batch)
ProductHistory.add_transfered_item(self.store,
self.transfer_order.source_branch,
self)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:13,代码来源:transfer.py
示例6: produce
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,代码行数:50,代码来源:production.py
示例7: confirm
def confirm(self):
"""Confirms the sale
"""
assert self.can_confirm()
assert self.branch
store = self.store
branch = self.branch
for item in self.get_items():
if item.sellable.product:
ProductHistory.add_decreased_item(store, branch, item)
item.decrease(branch)
self.status = StockDecrease.STATUS_CONFIRMED
if self.group:
self.group.confirm()
开发者ID:dionimf,项目名称:stoq,代码行数:18,代码来源:stockdecrease.py
示例8: add_lost
def add_lost(self, quantity):
"""Adds the quantity lost of this material. The maximum quantity that
can be lost is given by the formula::
- max_lost(quantity) = needed - consumed - lost - quantity
:param quantity: the quantity that was lost.
"""
assert quantity > 0
if self.lost + quantity > self.needed - self.consumed:
raise ValueError(_(u'Cannot loose this quantity.'))
required = self.consumed + self.lost + quantity
if required > self.allocated:
self.allocate(required - self.allocated)
self.lost += quantity
store = self.store
ProductHistory.add_lost_item(store, self.order.branch, self)
开发者ID:rosalin,项目名称:stoq,代码行数:20,代码来源:production.py
示例9: consume
def consume(self, quantity):
"""Consumes a certain quantity of material. The maximum quantity
allowed to be consumed is given by the following formula:
- max_consumed(quantity) = needed - consumed - lost - quantity
:param quantity: the quantity to be consumed.
"""
assert quantity > 0
available = self.allocated - self.consumed - self.lost
if quantity > available:
raise ValueError(_(u'Can not consume this quantity.'))
required = self.consumed + self.lost + quantity
if required > self.allocated:
self.allocate(required - self.allocated)
self.consumed += quantity
store = self.store
ProductHistory.add_consumed_item(store, self.order.branch, self)
开发者ID:rosalin,项目名称:stoq,代码行数:21,代码来源:production.py
示例10: apply_patch
def apply_patch(store):
# Creation of new column in stock_decrease table.
# And added new Cfop to cfop_data table.
store.execute("""ALTER TABLE stock_decrease
ADD COLUMN cfop_id bigint REFERENCES cfop_data(id);""")
# Default Cfop should be use in manual stock decrease.
cfop_data = store.find(CfopData, code=u'5.949').one()
if not cfop_data:
cfop_data = CfopData(store=store,
code=u"5.949",
description=u"Outra saída de mercadoria ou "
u"prestação de serviço não "
u"especificado")
# Adjusting existing manuals outputs
for stock_decrease in store.find(StockDecrease):
stock_decrease.cfop = cfop_data
retentions = store.execute("""
SELECT id, quantity, reason, retention_date, product_id, cfop_id
FROM product_retention_history ORDER BY id;""").get_all()
# Without retentions, there is no need to create user and employee
# variables.
if len(retentions):
# Default user for migration
user = get_admin_user(store)
if user is None:
users = Person.iselectBy(IUser, is_active=True,
store=store).order_by(Person.id)
user = users[0]
# Default employee for migration
employee = IEmployee(user.person, None)
if employee is None:
employees = Person.iselectBy(IEmployee, is_active=True,
store=store).order_by(Person.id)
employee = employees[0]
default_branch = sysparam(store).MAIN_COMPANY
notes = _(u"Stock decrease imported from old retention.")
history = store.execute("""
SELECT id, quantity_retained, sellable_id, branch_id
FROM product_history
WHERE quantity_retained is not null
ORDER BY id;""").get_all()
for i in range(len(retentions)):
ret = retentions[i]
hist = history[i]
product = Product.get(ret[4], store=store)
branch_id = hist[3]
if ret[1] != hist[1] or product.sellable.id != hist[2]:
branch_id = default_branch.id
decrease = StockDecrease(store=store,
confirm_date=ret[3],
status=StockDecrease.STATUS_CONFIRMED,
reason=ret[2],
notes=notes,
responsible=user,
removed_by=employee,
branch_id=branch_id,
cfop_id=ret[5])
decrease_item = StockDecreaseItem(store=store,
quantity=ret[1],
sellable=product.sellable)
decrease.add_item(decrease_item)
ProductHistory.delete(hist[0], store)
ProductHistory(branch_id=branch_id, sellable=product.sellable,
quantity_decreased=decrease_item.quantity,
decreased_date=decrease.confirm_date,
store=store)
store.execute("""ALTER TABLE product_history
DROP COLUMN quantity_retained;""")
store.execute("DROP TABLE product_retention_history;")
开发者ID:leandrorchaves,项目名称:stoq,代码行数:84,代码来源:patch-02-23.py
注:本文中的stoqlib.domain.product.ProductHistory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论