mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +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.stocktake_date = datetime.now().date()
|
||||||
self.save()
|
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):
|
def add_stock(self, amount):
|
||||||
""" Add items to stock
|
""" Add items to stock
|
||||||
This function can be called by initiating a ProjectRun,
|
This function can be called by initiating a ProjectRun,
|
||||||
@ -119,6 +98,9 @@ class StockItem(models.Model):
|
|||||||
self.quantity = q
|
self.quantity = q
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def take_stock(self, amount):
|
||||||
|
self.add_stock(-amount)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{n} x {part} @ {loc}".format(
|
return "{n} x {part} @ {loc}".format(
|
||||||
n=self.quantity,
|
n=self.quantity,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user