2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-14 08:19:54 +00:00

Stock available (#3057)

* Fix display of stock labels

- If 'shipped' or 'installed', don't display 'allocated' flag

* Switch stock item data around

* Add 'available' and 'allocation' information to the StockItem detail page

- Cache some context data to the view renderer

* Stock table now also displays allocation informatoin
This commit is contained in:
Oliver
2022-05-24 15:35:04 +10:00
committed by GitHub
parent 1c6e5f0f20
commit ea9f2f81f1
3 changed files with 223 additions and 185 deletions

View File

@@ -94,6 +94,12 @@ class StockItemDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
data['item_owner'] = self.object.get_item_owner()
data['user_owns_item'] = self.object.check_ownership(self.request.user)
# Allocation information
data['allocated_to_sales_orders'] = self.object.sales_order_allocation_count()
data['allocated_to_build_orders'] = self.object.build_allocation_count()
data['allocated_to_orders'] = data['allocated_to_sales_orders'] + data['allocated_to_build_orders']
data['available'] = max(0, self.object.quantity - data['allocated_to_orders'])
return data
def get(self, request, *args, **kwargs):