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

Add verbose names for multiple Build model fields

- Improve methods for different models
This commit is contained in:
Oliver Walters
2020-04-25 23:17:07 +10:00
parent 181d1d6b91
commit 01a68270ea
10 changed files with 318 additions and 90 deletions

View File

@ -426,6 +426,14 @@ class StockItem(MPTTModel):
return self.build_allocation_count() + self.sales_order_allocation_count()
def unallocated_quantity(self):
"""
Return the quantity of this StockItem which is *not* allocated
"""
return max(self.quantity - self.allocation_count(), 0)
def can_delete(self):
""" Can this stock item be deleted? It can NOT be deleted under the following circumstances:

View File

@ -34,6 +34,7 @@ class StockItemSerializerBrief(InvenTreeModelSerializer):
location_name = serializers.CharField(source='location', read_only=True)
part_name = serializers.CharField(source='part.full_name', read_only=True)
quantity = serializers.FloatField()
class Meta:
model = StockItem