2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-15 08:48:11 +00:00

Clean up implementation of test report matching

This commit is contained in:
Oliver Walters
2020-08-23 21:03:29 +10:00
parent b7ae95686e
commit c849f618d5
5 changed files with 21 additions and 27 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