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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user