From cb1e7a6cc5466d2b81d8e1e1426bcda8d994d93c Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 19 Aug 2021 23:22:58 +0200 Subject: [PATCH] only process purchase_price if prices present --- InvenTree/part/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 1e45ea5f4c..d7ad577081 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1652,8 +1652,10 @@ class Part(MPTTModel): def get_purchase_price(self, quantity): currency = currency_code_default() - prices = [convert_money(item.purchase_price, currency).amount for item in self.stock_items.all()] - return min(prices) * quantity, max(prices) * quantity + prices = [convert_money(item.purchase_price, currency).amount for item in self.stock_items.all() if item.purchase_price] + if prices: + return min(prices) * quantity, max(prices) * quantity + return None @transaction.atomic def copy_bom_from(self, other, clear=True, **kwargs):