mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 13:35:40 +00:00
Add a 'full_name' field for Part
- Combines IPN | Name | Variant - Use this to display in most views
This commit is contained in:
@ -9,7 +9,7 @@ from .models import BomItem
|
||||
|
||||
class PartAdmin(ImportExportModelAdmin):
|
||||
|
||||
list_display = ('long_name', 'IPN', 'description', 'total_stock', 'category')
|
||||
list_display = ('full_name', 'description', 'total_stock', 'category')
|
||||
|
||||
|
||||
class PartCategoryAdmin(ImportExportModelAdmin):
|
||||
|
@ -202,14 +202,28 @@ class Part(models.Model):
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return "{n} - {d}".format(n=self.long_name, d=self.description)
|
||||
return "{n} - {d}".format(n=self.full_name, d=self.description)
|
||||
|
||||
@property
|
||||
def long_name(self):
|
||||
name = self.name
|
||||
def full_name(self):
|
||||
""" Format a 'full name' for this Part.
|
||||
|
||||
- IPN (if not null)
|
||||
- Part name
|
||||
- Part variant (if not null)
|
||||
"""
|
||||
|
||||
elements = []
|
||||
|
||||
if self.IPN:
|
||||
elements.append(self.IPN)
|
||||
|
||||
elements.append(self.name)
|
||||
|
||||
if self.variant:
|
||||
name += " | " + self.variant
|
||||
return name
|
||||
elements.append(self.variant)
|
||||
|
||||
return ' | '.join(elements)
|
||||
|
||||
def get_absolute_url(self):
|
||||
""" Return the web URL for viewing this part """
|
||||
@ -480,7 +494,7 @@ class Part(models.Model):
|
||||
for it in self.bom_items.all():
|
||||
line = []
|
||||
|
||||
line.append(it.sub_part.name)
|
||||
line.append(it.sub_part.full_name)
|
||||
line.append(it.sub_part.description)
|
||||
line.append(it.quantity)
|
||||
line.append(it.note)
|
||||
@ -611,8 +625,8 @@ class BomItem(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return "{n} x {child} to make {parent}".format(
|
||||
parent=self.part.name,
|
||||
child=self.sub_part.name,
|
||||
parent=self.part.full_name,
|
||||
child=self.sub_part.full_name,
|
||||
n=self.quantity)
|
||||
|
||||
|
||||
|
@ -34,14 +34,13 @@ class PartBriefSerializer(serializers.ModelSerializer):
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
image_url = serializers.CharField(source='get_image_url', read_only=True)
|
||||
|
||||
|
||||
class Meta:
|
||||
model = Part
|
||||
fields = [
|
||||
'pk',
|
||||
'url',
|
||||
'name',
|
||||
'variant',
|
||||
'full_name',
|
||||
'description',
|
||||
'available_stock',
|
||||
'image_url',
|
||||
@ -63,6 +62,7 @@ class PartSerializer(serializers.ModelSerializer):
|
||||
fields = [
|
||||
'pk',
|
||||
'url', # Link to the part detail page
|
||||
'full_name',
|
||||
'name',
|
||||
'variant',
|
||||
'image_url',
|
||||
@ -86,7 +86,7 @@ class PartSerializer(serializers.ModelSerializer):
|
||||
class PartStarSerializer(InvenTreeModelSerializer):
|
||||
""" Serializer for a PartStar object """
|
||||
|
||||
partname = serializers.CharField(source='part.name', read_only=True)
|
||||
partname = serializers.CharField(source='part.full_name', read_only=True)
|
||||
username = serializers.CharField(source='user.username', read_only=True)
|
||||
|
||||
class Meta:
|
||||
|
@ -17,7 +17,7 @@
|
||||
{% for allocation in part.build_allocation %}
|
||||
<tr>
|
||||
<td><a href="{% url 'build-detail' allocation.build.id %}">{{ allocation.build.title }}</a></td>
|
||||
<td>{{ allocation.build.quantity }} × <a href="{% url 'part-detail' allocation.build.part.id %}">{{ allocation.build.part.name }}</a></td>
|
||||
<td>{{ allocation.build.quantity }} × <a href="{% url 'part-detail' allocation.build.part.id %}">{{ allocation.build.part.full_name }}</a></td>
|
||||
<td>{{ allocation.quantity }}</td>
|
||||
<td>{% include "build_status.html" with build=allocation.build %}</td>
|
||||
</tr>
|
||||
|
@ -4,6 +4,6 @@ Deleting this entry will remove the BOM row from the following part:
|
||||
|
||||
<ul class='list-group'>
|
||||
<li class='list-group-item'>
|
||||
<b>{{ item.part.name }}</b> - <i>{{ item.part.description }}</i>
|
||||
<b>{{ item.part.full_name }}</b> - <i>{{ item.part.description }}</i>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
<h3>BOM Item</h3>
|
||||
<table class="table table-striped">
|
||||
<tr><td>Parent</td><td><a href="{% url 'part-bom' item.part.id %}">{{ item.part.name }}</a></td></tr>
|
||||
<tr><td>Child</td><td><a href="{% url 'part-used-in' item.sub_part.id %}">{{ item.sub_part.name }}</a></td></tr>
|
||||
<tr><td>Parent</td><td><a href="{% url 'part-bom' item.part.id %}">{{ item.part.full_name }}</a></td></tr>
|
||||
<tr><td>Child</td><td><a href="{% url 'part-used-in' item.sub_part.id %}">{{ item.sub_part.full_name }}</a></td></tr>
|
||||
<tr><td>Quantity</td><td>{{ item.quantity }}</td></tr>
|
||||
</table>
|
||||
|
||||
|
@ -27,7 +27,7 @@ the top level 'Parts' category.
|
||||
</p>
|
||||
<ul class='list-group'>
|
||||
{% for part in category.parts.all %}
|
||||
<li class='list-group-item'><b>{{ part.long_name }}</b> - <i>{{ part.description }}</i></li>
|
||||
<li class='list-group-item'><b>{{ part.full_name }}</b> - <i>{{ part.description }}</i></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
@ -10,7 +10,7 @@
|
||||
<ul class='list-group'>
|
||||
{% for match in matches %}
|
||||
<li class='list-group-item list-group-item-condensed'>
|
||||
{{ match.part.name }} - <i>{{ match.part.description }}</i> ({{ match.ratio }}%)
|
||||
{{ match.part.full_name }} - <i>{{ match.part.description }}</i> ({{ match.ratio }}%)
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -16,7 +16,6 @@
|
||||
{% if part.active %}
|
||||
<li><a href='#' id='duplicate-part' title='Duplicate Part'>Duplicate</a></li>
|
||||
<li><a href="#" id='edit-part' title='Edit part'>Edit</a></li>
|
||||
<li><a href='#' id='stocktake-part' title='Stocktake'>Stocktake</a></li>
|
||||
<hr>
|
||||
<li><a href="#" id='deactivate-part' title='Deactivate part'>Deactivate</a></li>
|
||||
{% else %}
|
||||
@ -34,7 +33,7 @@
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td>Part name</td>
|
||||
<td>{{ part.long_name }}</td>
|
||||
<td>{{ part.full_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
@ -46,6 +45,12 @@
|
||||
<td>{{ part.IPN }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if part.URL %}
|
||||
<tr>
|
||||
<td>URL</td>
|
||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>Category</td>
|
||||
<td>
|
||||
@ -147,7 +152,7 @@
|
||||
$('#activate-part').click(function() {
|
||||
showQuestionDialog(
|
||||
'Activate Part?',
|
||||
'Are you sure you wish to reactivate {{ part.long_name }}?',
|
||||
'Are you sure you wish to reactivate {{ part.full_name }}?',
|
||||
{
|
||||
accept_text: 'Activate',
|
||||
accept: function() {
|
||||
@ -169,7 +174,7 @@
|
||||
$('#deactivate-part').click(function() {
|
||||
showQuestionDialog(
|
||||
'Deactivate Part?',
|
||||
`Are you sure you wish to deactivate {{ part.long_name }}?<br>
|
||||
`Are you sure you wish to deactivate {{ part.full_name }}?<br>
|
||||
`,
|
||||
{
|
||||
accept_text: 'Deactivate',
|
||||
@ -198,16 +203,4 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('#stocktake-part').click(function() {
|
||||
adjustStock({
|
||||
action: 'stocktake',
|
||||
query: {
|
||||
part: {{ part.id }},
|
||||
},
|
||||
success: function() {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
{% endblock %}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% block page_title %}
|
||||
{% if part %}
|
||||
InvenTree | Part - {{ part.long_name }}
|
||||
InvenTree | Part - {{ part.full_name }}
|
||||
{% elif category %}
|
||||
InvenTree | Part Category - {{ category }}
|
||||
{% else %}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="row">
|
||||
{% if part.active == False %}
|
||||
<div class='alert alert-danger' style='display: block;'>
|
||||
This part ({{ part.long_name }}) is not active:
|
||||
This part ({{ part.full_name }}) is not active:
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-sm-6">
|
||||
@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h4>
|
||||
{{ part.long_name }}
|
||||
{{ part.full_name }}
|
||||
</h4>
|
||||
{% if part.variant %}
|
||||
<p>Variant: {{ part.variant }}</p>
|
||||
|
@ -1,10 +1,10 @@
|
||||
Are you sure you want to delete part '{{ part.long_name }}'?
|
||||
Are you sure you want to delete part '{{ part.full_name }}'?
|
||||
|
||||
{% if part.used_in_count %}
|
||||
<p>This part is used in BOMs for {{ part.used_in_count }} other parts. If you delete this part, the BOMs for the following parts will be updated:
|
||||
<ul class="list-group">
|
||||
{% for child in part.used_in.all %}
|
||||
<li class='list-group-item'>{{ child.part.name }} - {{ child.part.description }}</li>
|
||||
<li class='list-group-item'>{{ child.part.full_name }} - {{ child.part.description }}</li>
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
@ -30,5 +30,5 @@ Are you sure you want to delete part '{{ part.long_name }}'?
|
||||
{% endif %}
|
||||
|
||||
{% if part.serials.all|length > 0 %}
|
||||
<p>There are {{ part.serials.all|length }} unique parts tracked for '{{ part.long_name }}'. Deleting this part will permanently remove this tracking information.</p>
|
||||
<p>There are {{ part.serials.all|length }} unique parts tracked for '{{ part.full_name }}'. Deleting this part will permanently remove this tracking information.</p>
|
||||
{% endif %}
|
@ -48,7 +48,7 @@
|
||||
$("#supplier-table").bootstrapTable({
|
||||
sortable: true,
|
||||
search: true,
|
||||
formatNoMatches: function() { return "No supplier parts available for {{ part.long_name }}"; },
|
||||
formatNoMatches: function() { return "No supplier parts available for {{ part.full_name }}"; },
|
||||
queryParams: function(p) {
|
||||
return {
|
||||
part: {{ part.id }}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% include 'part/tabs.html' with tab='track' %}
|
||||
|
||||
Part tracking for {{ part.long_name }}
|
||||
Part tracking for {{ part.full_name }}
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
|
@ -27,7 +27,7 @@
|
||||
$("#used-table").bootstrapTable({
|
||||
sortable: true,
|
||||
search: true,
|
||||
formatNoMatches: function() { return "{{ part.long_name }} is not used to make any other parts"; },
|
||||
formatNoMatches: function() { return "{{ part.full_name }} is not used to make any other parts"; },
|
||||
queryParams: function(p) {
|
||||
return {
|
||||
sub_part: {{ part.id }}
|
||||
@ -43,7 +43,7 @@
|
||||
field: 'part_detail',
|
||||
title: 'Part',
|
||||
formatter: function(value, row, index, field) {
|
||||
return imageHoverIcon(row.part_detail.image_url) + renderLink(value.name, value.url + 'bom/');
|
||||
return imageHoverIcon(row.part_detail.image_url) + renderLink(value.full_name, value.url + 'bom/');
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user