2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

only process purchase_price if prices present

This commit is contained in:
Matthias 2021-08-19 23:22:58 +02:00
parent 00d4efb920
commit cb1e7a6cc5
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -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):