2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 19:20:55 +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

@ -202,6 +202,17 @@ class TestReport(ReportTemplateBase, PartFilterMixin):
# Requires a stock_item object to be given to it before rendering
stock_item = None
def matches_stock_item(self, item):
"""
Test if this report template matches a given StockItem objects
"""
filters = validateFilterString(self.part_filters)
items = StockItem.objects.filter(**filters)
return items.exists()
def get_context_data(self, request):
return {
'stock_item': self.stock_item,