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): def get_purchase_price(self, quantity):
currency = currency_code_default() currency = currency_code_default()
prices = [convert_money(item.purchase_price, currency).amount for item in self.stock_items.all()] 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 min(prices) * quantity, max(prices) * quantity
return None
@transaction.atomic @transaction.atomic
def copy_bom_from(self, other, clear=True, **kwargs): def copy_bom_from(self, other, clear=True, **kwargs):