2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Merge branch 'master' into feature-non-int-serial

This commit is contained in:
Ben Charlton
2020-08-24 11:12:07 +01:00
14 changed files with 172 additions and 176 deletions

View File

@ -15,6 +15,8 @@ from InvenTree.helpers import GetExportFormats
from InvenTree.forms import HelperForm
from InvenTree.fields import RoundingDecimalFormField
from report.models import TestReport
from .models import StockLocation, StockItem, StockItemTracking
from .models import StockItemAttachment
from .models import StockItemTestResult
@ -225,12 +227,17 @@ class TestReportFormatForm(HelperForm):
self.fields['template'].choices = self.get_template_choices()
def get_template_choices(self):
""" Available choices """
"""
Generate a list of of TestReport options for the StockItem
"""
choices = []
for report in self.stock_item.part.get_test_report_templates():
choices.append((report.pk, report))
templates = TestReport.objects.filter(enabled=True)
for template in templates:
if template.matches_stock_item(self.stock_item):
choices.append(template)
return choices

View File

@ -124,11 +124,9 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% endif %}
</ul>
</div>
{% if item.part.has_test_report_templates %}
<button type='button' class='btn btn-default' id='stock-test-report' title='{% trans "Generate test report" %}'>
<span class='fas fa-file-invoice'/>
</button>
{% endif %}
</div>
{% endblock %}
@ -303,7 +301,6 @@ $("#stock-serialize").click(function() {
);
});
{% if item.part.has_test_report_templates %}
$("#stock-test-report").click(function() {
launchModalForm(
"{% url 'stock-item-test-report-select' item.id %}",
@ -312,7 +309,6 @@ $("#stock-test-report").click(function() {
}
);
});
{% endif %}
$("#print-label").click(function() {
launchModalForm(

View File

@ -17,9 +17,7 @@
<button type='button' class='btn btn-danger' id='delete-test-results'>{% trans "Delete Test Data" %}</button>
{% endif %}
<button type='button' class='btn btn-success' id='add-test-result'>{% trans "Add Test Data" %}</button>
{% if item.part.has_test_report_templates %}
<button type='button' class='btn btn-default' id='test-report'>{% trans "Test Report" %} <span class='fas fa-tasks'></span></button>
{% endif %}
</div>
<div class='filter-list' id='filter-list-stocktests'>
<!-- Empty div -->

View File

@ -310,7 +310,8 @@ class StockItemSelectLabels(AjaxView):
labels = []
for label in StockItemLabel.objects.all():
# Construct a list of StockItemLabel objects which are enabled, and the filters match the selected StockItem
for label in StockItemLabel.objects.filter(enabled=True):
if label.matches_stock_item(item):
labels.append(label)