mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Code cleanup
This commit is contained in:
parent
41485e0e0f
commit
92cbd43f0f
@ -78,27 +78,6 @@ class StockItem(models.Model):
|
||||
self.stocktake_date = datetime.now().date()
|
||||
self.save()
|
||||
|
||||
def take_stock(self, amount):
|
||||
""" Take items from stock
|
||||
This function can be called by initiating a ProjectRun,
|
||||
or by manually taking the items from the stock location
|
||||
"""
|
||||
|
||||
if self.infinite:
|
||||
return
|
||||
|
||||
amount = int(amount)
|
||||
if amount < 0:
|
||||
raise ValueError("Stock amount must be positive")
|
||||
|
||||
q = self.quantity - amount
|
||||
|
||||
if q < 0:
|
||||
q = 0
|
||||
|
||||
self.quantity = q
|
||||
self.save()
|
||||
|
||||
def add_stock(self, amount):
|
||||
""" Add items to stock
|
||||
This function can be called by initiating a ProjectRun,
|
||||
@ -119,6 +98,9 @@ class StockItem(models.Model):
|
||||
self.quantity = q
|
||||
self.save()
|
||||
|
||||
def take_stock(self, amount):
|
||||
self.add_stock(-amount)
|
||||
|
||||
def __str__(self):
|
||||
return "{n} x {part} @ {loc}".format(
|
||||
n=self.quantity,
|
||||
|
Loading…
Reference in New Issue
Block a user