mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-02 10:18:42 +00:00
[refactor] Optional prefetch (#11012)
* Automatic prefetch of related fields for enable_filter - Allows us to *not* prefetch fields (expensive) when they are not going to be used - Enables re-usable components for common detail fields * Refactor "project_code_detail" filter into common component - Automatically apply correct prefetch fields * Refactor 'parameters' annotation - add 'enable_parameters_filter' function - Prefetch parameters only when needed - Refactor / consolidate code * Refactor SupplierPartSerializer - Make fields switchable - Ensure correct prefetch_related * Refactor serializer for ManufacturerPart * Refactor BuildSerializer * Refactor PurchaseOrderSerializer * Refactor SalesOrderSerializer * Refactor ReturnOrderSerializer * Remove debug statements * Tweaks * Simplify custom filterable fields * Bump API version * Fix for data export * Additional unit tests * Remove unused "prefetch_func" option * Refactor PurchaseOrderLineItemList * Refactor SalesOrderLineItemList * Refactor ReturnOrderLineItem * Cleanup "pretty_name" * Fix for build list * Refactoring StockItem API endpoint - Needs significant work still * Refactoring for BuildLineSerializer * Keep all optional fields when exporting data * Improve "UserRoles" API endpoint - Prefetch roles - Prevents significant number of db hits * Prefetch Parameter API list * Bug fix for exporting logic * Specify InvenTreeOutputOption * Optional prefetch for primary_address * Fix typing * Fix unit test * fixes for playwright tests * Update Part API - Improved prefetching * Fix for prefetch
This commit is contained in:
@@ -1989,17 +1989,16 @@ class PurchaseOrderLineItem(OrderLineItem):
|
||||
def get_destination(self):
|
||||
"""Show where the line item is or should be placed.
|
||||
|
||||
NOTE: If a line item gets split when received, only an arbitrary
|
||||
stock items location will be reported as the location for the
|
||||
entire line.
|
||||
1. If a destination is specified against this line item, return that.
|
||||
2. If a destination is specified against the PurchaseOrderPart, return that.
|
||||
3. If a default location is specified against the linked Part, return that.
|
||||
"""
|
||||
for item in stock.models.StockItem.objects.filter(
|
||||
supplier_part=self.part, purchase_order=self.order
|
||||
):
|
||||
if item.location:
|
||||
return item.location
|
||||
if self.destination:
|
||||
return self.destination
|
||||
|
||||
if self.order.destination:
|
||||
return self.order.destination
|
||||
|
||||
if self.part and self.part.part and self.part.part.default_location:
|
||||
return self.part.part.default_location
|
||||
|
||||
|
||||
Reference in New Issue
Block a user