From a6b52a9fae5eb1510234f59e384772675d03c5d5 Mon Sep 17 00:00:00 2001 From: eeintech Date: Mon, 26 Jul 2021 17:02:04 -0400 Subject: [PATCH] Fix for #1861 --- InvenTree/part/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 28e5d4300a..8d0ad5452d 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -995,8 +995,9 @@ class BomList(generics.ListCreateAPIView): # Get values for currencies currencies = queryset.annotate( + purchase_price=F('sub_part__stock_items__purchase_price'), purchase_price_currency=F('sub_part__stock_items__purchase_price_currency'), - ).values('pk', 'sub_part', 'purchase_price_currency') + ).values('pk', 'sub_part', 'purchase_price', 'purchase_price_currency') def convert_price(price, currency, decimal_places=4): """ Convert price field, returns Money field """ @@ -1032,7 +1033,7 @@ class BomList(generics.ListCreateAPIView): # Find associated currency (select first found) purchase_price_currency = None for currency_item in currencies: - if currency_item['pk'] == bom_item.pk and currency_item['sub_part'] == bom_item.sub_part.pk: + if currency_item['pk'] == bom_item.pk and currency_item['sub_part'] == bom_item.sub_part.pk and currency_item['purchase_price']: purchase_price_currency = currency_item['purchase_price_currency'] break # Convert prices