2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-06 05:30:56 +00:00

Fix "in_stock" logic for StockItem

- Not in stock if it is at a customer!
This commit is contained in:
Oliver Walters
2020-08-08 09:20:42 +10:00
parent 861a2982db
commit ff71fe6e93
2 changed files with 9 additions and 5 deletions

View File

@ -140,6 +140,7 @@ class StockItem(MPTTModel):
sales_order=None,
build_order=None,
belongs_to=None,
customer=None,
status__in=StockStatus.AVAILABLE_CODES
)
@ -609,6 +610,10 @@ class StockItem(MPTTModel):
if self.build_order is not None:
return False
# Not 'in stock' if it has been assigned to a customer
if self.customer is not None:
return False
# Not 'in stock' if the status code makes it unavailable
if self.status in StockStatus.UNAVAILABLE_CODES:
return False