2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

Expose "is_allocated" parameter on StockItem API

This commit is contained in:
Oliver Walters
2020-04-22 10:11:40 +10:00
parent 12daf15406
commit 6dd79af0b6
7 changed files with 68 additions and 2 deletions

View File

@ -397,6 +397,16 @@ class StockItem(MPTTModel):
infinite = models.BooleanField(default=False)
def is_allocated(self):
"""
Return True if this StockItem is allocated to a SalesOrder or a Build
"""
# TODO - For now this only checks if the StockItem is allocated to a SalesOrder
# TODO - In future, once the "build" is working better, check this too
return self.sales_order_line is not None
def can_delete(self):
""" Can this stock item be deleted? It can NOT be deleted under the following circumstances: