From f1f0027cef6cd4217b754de525c0e5b9c7336457 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 11 Mar 2022 02:10:21 +0100 Subject: [PATCH] fix wrong reference for POs --- InvenTree/order/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 2dd0a5e54f..4efa76449f 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -158,8 +158,10 @@ class Order(ReferenceIndexingMixin): target_currency = currency_code_default() total = Money(0, target_currency) + # gather name reference + price_ref = 'sale_price' if isinstance(self, SalesOrder) else 'purchase_price' # order items - total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.lines.all() if a.sale_price]) + total += sum([a.quantity * convert_money(getattr(a, price_ref), target_currency) for a in self.lines.all() if hasattr(a, price_ref)]) # additional lines total += sum([a.quantity * convert_money(a.sale_price, target_currency) for a in self.additional_lines.all() if a.sale_price])