mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-05 09:55:28 +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(customer=None)
|
||||||
stock_items = stock_items.filter(belongs_to=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
|
# Column headers
|
||||||
headers = [
|
headers = [
|
||||||
_('Stock ID'),
|
_('Stock ID'),
|
||||||
|
|||||||
Reference in new issue
Block a user