From 713549fe6a1bde8c5c6b716b24d9f67b2c7cc4a2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 1 Dec 2021 08:14:49 +1100 Subject: [PATCH] Handle case where issue_date is not set --- InvenTree/part/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index cd9ea6b41a..6e742dc571 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -439,10 +439,14 @@ class PartDetail(InvenTreeRoleMixin, DetailView): line['price_part'] = stock_item.supplier_part.unit_pricing # set date for graph labels - if stock_item.purchase_order: + if stock_item.purchase_order and stock_item.purchase_order.issue_date: line['date'] = stock_item.purchase_order.issue_date.strftime('%d.%m.%Y') - else: + elif stock_item.tracking_info.count() > 0: line['date'] = stock_item.tracking_info.first().date.strftime('%d.%m.%Y') + else: + # Not enough information + continue + price_history.append(line) ctx['price_history'] = price_history