2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

Add 'to_order' and 'to_build' collapsible panels

This commit is contained in:
Oliver Walters
2019-05-02 20:18:34 +10:00
parent 4d7ac870e0
commit 38100520df
8 changed files with 90 additions and 6 deletions

View File

@ -193,14 +193,25 @@ class Part(models.Model):
def available_stock(self):
"""
Return the total available stock.
This subtracts stock which is already allocated
- This subtracts stock which is already allocated to builds
"""
total = self.total_stock
total -= self.allocation_count
return max(total, 0)
return total
def need_to_restock(self):
""" Return True if this part needs to be restocked
(either by purchasing or building).
If the allocated_stock exceeds the total_stock,
then we need to restock.
"""
return (self.total_stock - self.allocation_count) < self.minimum_stock
@property
def can_build(self):