mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-04 09:25:21 +00:00
Prefecth related data for stock export
- Example export reduced from 1,024 queries to 7
This commit is contained in:
1 parent
d8a3c7a81d
commit
108382cc89
1 file changed
+3
@@ -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'),
|
||||
|
||||
Reference in new issue
Block a user