2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-28 14:25:56 +00:00

Add ability to filter by 'expired' status in API

This commit is contained in:
Oliver Walters
2021-01-04 00:19:48 +11:00
parent 07cda765f0
commit 6d4c81e68b
2 changed files with 14 additions and 0 deletions

View File

@@ -150,6 +150,9 @@ class StockItem(MPTTModel):
status__in=StockStatus.AVAILABLE_CODES
)
# A query filter which can be used to filter StockItem objects which have expired
EXPIRED_FILTER = IN_STOCK_FILTER & ~Q(expiry_date=None) & Q(expiry_date__lt=datetime.now().date())
def save(self, *args, **kwargs):
"""
Save this StockItem to the database. Performs a number of checks: