Fix for update_pricing method: (#7075)

- Specify currency
- Handle case where quantity is zero
This commit is contained in:
Oliver 2024-04-22 13:51:22 +10:00 committed by GitHub
parent 9a16a73ad3
commit 50ca493667
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1459,9 +1459,11 @@ class PurchaseOrderLineItem(OrderLineItem):
def update_pricing(self):
"""Update pricing information based on the supplier part data."""
if self.part:
price = self.part.get_price(self.quantity)
price = self.part.get_price(
self.quantity, currency=self.purchase_price_currency
)
if price is None:
if price is None or self.quantity == 0:
return
self.purchase_price = Decimal(price) / Decimal(self.quantity)