From 50ca493667e9e56f3f2e34c8fd9665fdf11050ba Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 22 Apr 2024 13:51:22 +1000 Subject: [PATCH] Fix for update_pricing method: (#7075) - Specify currency - Handle case where quantity is zero --- src/backend/InvenTree/order/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/InvenTree/order/models.py b/src/backend/InvenTree/order/models.py index f33fcd53ab..94710c01a9 100644 --- a/src/backend/InvenTree/order/models.py +++ b/src/backend/InvenTree/order/models.py @@ -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)