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
This commit is contained in:
Adam Walsh 2021-06-21 11:20:43 -04:00
parent f90730d866
commit d1a2ed9af1
No known key found for this signature in database
GPG Key ID: E770242294A6CF59
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -350,7 +350,12 @@
<tr>
<td><span class='fas fa-industry'></span></td>
<td>{% trans "Manufacturer" %}</td>
<td><a href="{% url 'company-detail' item.supplier_part.manufacturer_part.manufacturer.id %}">{{ item.supplier_part.manufacturer_part.manufacturer.name }}</a></td>
{% if item.supplier_part.manufacturer_part.manufacturer %}
<td><a href="{% url 'company-detail' item.supplier_part.manufacturer_part.manufacturer.id %}">{{ item.supplier_part.manufacturer_part.manufacturer.name }}</a></td>
{% else %}
<td><i>{% trans "No manufacturer set" %}</i></td>
{% endif %}
</tr>
<tr>
<td><span class='fas fa-hashtag'></span></td>