This commit is contained in:
Oliver Walters 2021-01-18 22:25:53 +11:00
parent 697a338700
commit 526d81481b
11 changed files with 51 additions and 82 deletions

View File

@ -1856,9 +1856,6 @@ class BomItem(models.Model):
self.clean()
super().save(*args, **kwargs)
def get_absolute_url(self):
return reverse('bom-item-detail', kwargs={'pk': self.id})
# A link to the parent part
# Each part will get a reverse lookup field 'bom_items'
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='bom_items',

View File

@ -1,10 +1,11 @@
{% load i18n %}
{% extends "modal_delete_form.html" %}
{% block pre_form_content %}
Are you sure you want to delete this BOM item?
{% trans "Are you sure you want to delete this BOM item?" %}
<br>
Deleting this entry will remove the BOM row from the following part:
{% trans "Deleting this entry will remove the BOM row from the following part" %}:
<ul class='list-group'>
<li class='list-group-item'>

View File

@ -1,18 +0,0 @@
{% extends "base.html" %}
{% block content %}
<h3>BOM Item</h3>
<table class="table table-striped">
<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>
<div class='container-fluid'>
<a href="{% url 'bom-item-edit' item.id %}"><button class="btn btn-info">Edit BOM item</button></a>
<a href="{% url 'bom-item-delete' item.id %}"><button class="btn btn-danger">Delete BOM item</button></a>
</div>
{% endblock %}

View File

@ -63,9 +63,9 @@
<span class='fas fa-file-download'></span> {% trans "Export" %}
</button>
{% endif %}
</div>
<div class='filter-list' id='filter-list-bom'>
<!-- Empty div (will be filled out with avilable BOM filters) -->
<div class='filter-list' id='filter-list-bom'>
<!-- Empty div (will be filled out with avilable BOM filters) -->
</div>
</div>
</div>
@ -179,8 +179,8 @@
secondary: [
{
field: 'sub_part',
label: 'New Part',
title: 'Create New Part',
label: '{% trans "New Part" %}',
title: '{% trans "Create New Part" %}',
url: "{% url 'part-create' %}",
},
]

View File

@ -49,14 +49,14 @@
{% for row in bom_rows %}
<tr {% if row.errors %} style='background: #ffeaea;'{% endif %} part-name='{{ row.part_name }}' part-description='{{ row.description }}' part-select='#select_part_{{ row.index }}'>
<td>
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
<button class='btn btn-default btn-remove' onClick='removeRowFromBomWizard()' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='{% trans "Remove row" %}'>
<span row_id='{{ forloop.counter }}' class='fas fa-trash-alt icon-red'></span>
</button>
</td>
<td></td>
<td>{% add row.index 1 %}</td>
<td>
<button class='btn btn-default btn-create' onClick='newPartFromBomWizard()' id='new_part_row_{{ row.index }}' title='Create new part' type='button'>
<button class='btn btn-default btn-create' onClick='newPartFromBomWizard()' id='new_part_row_{{ row.index }}' title='{% trans "Create new part" %}' type='button'>
<span row_id='{{ row.index }}' class='fas fa-plus icon-green'/>
</button>
<select class='select bomselect' id='select_part_{{ row.index }}' name='part_{{ row.index }}'>

View File

@ -126,9 +126,9 @@
<li><a href='#' id='multi-part-export' title='{% trans "Export" %}'>{% trans "Export Data" %}</a></li>
</ul>
</div>
</div>
<div class='filter-list' id='filter-list-parts'>
<!-- Empty div -->
<div class='filter-list' id='filter-list-parts'>
<!-- Empty div -->
</div>
</div>
</div>

View File

@ -1,3 +1,4 @@
{% load i18n %}
{% extends "modal_form.html" %}
{% block pre_form_content %}
@ -10,8 +11,8 @@
</div>
{% if matches %}
<b>Possible Matching Parts</b>
<p>The new part may be a duplicate of these existing parts:</p>
<b>{% trans "Possible Matching Parts" %}</b>
<p>{% trans "The new part may be a duplicate of these existing parts" %}:</p>
<ul class='list-group'>
{% for match in matches %}
<li class='list-group-item list-group-item-condensed'>

View File

@ -1,3 +1,4 @@
{% load i18n %}
{% extends "modal_form.html" %}
{% block pre_form_content %}
@ -5,8 +6,8 @@
{{ block.super }}
<div class='alert alert-info alert-block'>
<b>Create new part variant</b><br>
Create a new variant of template <i>'{{ part.full_name }}'</i>.
<b>{% trans "Create new part variant" %}</b><br>
{% trans "Create a new variant of template" %} <i>'{{ part.full_name }}'</i>.
</div>
{% endblock %}

View File

@ -99,8 +99,6 @@ part_category_urls = [
part_bom_urls = [
url(r'^edit/?', views.BomItemEdit.as_view(), name='bom-item-edit'),
url('^delete/?', views.BomItemDelete.as_view(), name='bom-item-delete'),
url(r'^.*$', views.BomItemDetail.as_view(), name='bom-item-detail'),
]
# URL list for part web interface

View File

@ -2411,15 +2411,6 @@ class CategoryParameterTemplateDelete(AjaxDeleteView):
return self.object
class BomItemDetail(InvenTreeRoleMixin, DetailView):
""" Detail view for BomItem """
context_object_name = 'item'
queryset = BomItem.objects.all()
template_name = 'part/bom-detail.html'
role_required = 'part.view'
class BomItemCreate(AjaxCreateView):
""" Create view for making a new BomItem object """
model = BomItem

View File

@ -214,47 +214,45 @@ function loadBomTable(table, options) {
},
});
if (!options.editable) {
cols.push(
{
field: 'sub_part_detail.stock',
title: '{% trans "Available" %}',
searchable: false,
sortable: true,
formatter: function(value, row, index, field) {
cols.push(
{
field: 'sub_part_detail.stock',
title: '{% trans "Available" %}',
searchable: false,
sortable: true,
formatter: function(value, row, index, field) {
var url = `/part/${row.sub_part_detail.pk}/stock/`;
var text = value;
var url = `/part/${row.sub_part_detail.pk}/stock/`;
var text = value;
if (value == null || value <= 0) {
text = `<span class='label label-warning'>{% trans "No Stock" %}</span>`;
}
return renderLink(text, url);
if (value == null || value <= 0) {
text = `<span class='label label-warning'>{% trans "No Stock" %}</span>`;
}
});
/*
return renderLink(text, url);
}
});
// TODO - Re-introduce the pricing column at a later stage,
// once the pricing has been "fixed"
// O.W. 2020-11-24
/*
cols.push(
{
field: 'price_range',
title: '{% trans "Price" %}',
sortable: true,
formatter: function(value, row, index, field) {
if (value) {
return value;
} else {
return "<span class='warning-msg'>{% trans "No pricing available" %}</span>";
}
// TODO - Re-introduce the pricing column at a later stage,
// once the pricing has been "fixed"
// O.W. 2020-11-24
cols.push(
{
field: 'price_range',
title: '{% trans "Price" %}',
sortable: true,
formatter: function(value, row, index, field) {
if (value) {
return value;
} else {
return "<span class='warning-msg'>{% trans "No pricing available" %}</span>";
}
});
*/
}
}
});
*/
cols.push(
{