mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Prefecth related data for stock export
- Example export reduced from 1,024 queries to 7
This commit is contained in:
parent
d8a3c7a81d
commit
108382cc89
@ -223,6 +223,9 @@ class StockExport(AjaxView):
|
||||
stock_items = stock_items.filter(customer=None)
|
||||
stock_items = stock_items.filter(belongs_to=None)
|
||||
|
||||
# Pre-fetch related fields to reduce DB queries
|
||||
stock_items = stock_items.prefetch_related('part', 'supplier_part__supplier', 'location', 'purchase_order', 'build')
|
||||
|
||||
# Column headers
|
||||
headers = [
|
||||
_('Stock ID'),
|
||||
|
Loading…
Reference in New Issue
Block a user