From d1a2ed9af17801aceec415fa56d343ff527ff29d Mon Sep 17 00:00:00 2001 From: Adam Walsh Date: Mon, 21 Jun 2021 11:20:43 -0400 Subject: [PATCH] Fix supplier part view/edit without a manufacturer Fixes the following issues when a supplier part was created with an MPN but no manufacturer was assigned: - Viewing a supplier part stock item - Editing a supplier part stock item --- InvenTree/company/views.py | 3 ++- InvenTree/stock/templates/stock/item_base.html | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/InvenTree/company/views.py b/InvenTree/company/views.py index b2f655737f..74a583710a 100644 --- a/InvenTree/company/views.py +++ b/InvenTree/company/views.py @@ -623,7 +623,8 @@ class SupplierPartEdit(AjaxUpdateView): supplier_part = self.get_object() if supplier_part.manufacturer_part: - initials['manufacturer'] = supplier_part.manufacturer_part.manufacturer.id + if supplier_part.manufacturer_part.manufacturer: + initials['manufacturer'] = supplier_part.manufacturer_part.manufacturer.id initials['MPN'] = supplier_part.manufacturer_part.MPN return initials diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 7aebd51452..bf9d10590f 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -350,7 +350,12 @@ {% trans "Manufacturer" %} - {{ item.supplier_part.manufacturer_part.manufacturer.name }} + {% if item.supplier_part.manufacturer_part.manufacturer %} + {{ item.supplier_part.manufacturer_part.manufacturer.name }} + {% else %} + {% trans "No manufacturer set" %} + {% endif %} +