Merge pull request #1842 from SchrodingersGat/installed-items

Add "installed_items" as a context variable to TestReport
This commit is contained in:
Oliver 2021-07-19 17:23:56 +10:00 committed by GitHub
commit ca36775f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -357,7 +357,8 @@ class TestReport(ReportTemplateBase):
'serial': stock_item.serial,
'part': stock_item.part,
'results': stock_item.testResultMap(include_installed=self.include_installed),
'result_list': stock_item.testResultList(include_installed=self.include_installed)
'result_list': stock_item.testResultList(include_installed=self.include_installed),
'installed_items': stock_item.get_installed_items(cascade=True),
}

View File

@ -56,6 +56,10 @@ content: "{% trans 'Stock Item Test Report' %}";
{% endblock %}
{% block pre_page_content %}
{% endblock %}
{% block page_content %}
<div class='container'>
@ -80,6 +84,7 @@ content: "{% trans 'Stock Item Test Report' %}";
</div>
</div>
{% if resul_list|length > 0 %}
<h3>{% trans "Test Results" %}</h3>
<table class='table test-table'>
@ -112,5 +117,37 @@ content: "{% trans 'Stock Item Test Report' %}";
</tbody>
</table>
{% endif %}
{% if installed_items|length > 0 %}
<h3>{% trans "Installed Items" %}</h3>
<table class='table test-table'>
<thead>
</thead>
<tbody>
{% for sub_item in installed_items %}
<tr>
<td>
<img src='{% part_image sub_item.part %}' class='part-img' style='max-width: 24px; max-height: 24px;'>
{{ sub_item.part.full_name }}
</td>
<td>
{% if sub_item.serialized %}
{% trans "Serial" %}: {{ sub_item.serial }}
{% else %}
{% trans "Quantity" %}: {% decimal sub_item.quantity %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock %}
{% block post_page_content %}
{% endblock %}