mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "child build" page
This commit is contained in:
parent
2186a66465
commit
c1dd5b1ca1
@ -259,6 +259,23 @@ class Build(MPTTModel):
|
||||
blank=True, help_text=_('Extra build notes')
|
||||
)
|
||||
|
||||
def sub_builds(self, cascade=True):
|
||||
"""
|
||||
Return all Build Order objects under this one.
|
||||
"""
|
||||
|
||||
if cascade:
|
||||
return Build.objects.filter(parent=self.pk)
|
||||
else:
|
||||
descendants = self.get_descendants(include_self=True)
|
||||
Build.objects.filter(parent__pk__in=[d.pk for d in descendants])
|
||||
|
||||
|
||||
def sub_build_count(self, cascade=True):
|
||||
|
||||
return self.sub_builds(cascade=cascade).count()
|
||||
|
||||
|
||||
@property
|
||||
def is_overdue(self):
|
||||
"""
|
||||
|
16
InvenTree/build/templates/build/build_children.html
Normal file
16
InvenTree/build/templates/build/build_children.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends "build/build_base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
{% include "build/tabs.html" with tab="children" %}
|
||||
|
||||
<h4>{% trans "Child Build Orders" %}</h4>
|
||||
|
||||
<hr>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{% endblock %}
|
@ -24,6 +24,12 @@
|
||||
<span class='badge'>{{ build.output_count }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li {% if tab == 'children' %} class='active'{% endif %}>
|
||||
<a href='{% url "build-children" build.id %}'>
|
||||
{% trans "Child Builds" %}
|
||||
<span class='badge'>{{ build.sub_build_count }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li{% if tab == 'notes' %} class='active'{% endif %}>
|
||||
<a href="{% url 'build-notes' build.id %}">
|
||||
{% trans "Notes" %}
|
||||
|
@ -20,6 +20,7 @@ build_detail_urls = [
|
||||
|
||||
url(r'^notes/', views.BuildNotes.as_view(), name='build-notes'),
|
||||
|
||||
url(r'^children/', views.BuildDetail.as_view(template_name='build/build_children.html'), name='build-children'),
|
||||
url(r'^parts/', views.BuildDetail.as_view(template_name='build/parts.html'), name='build-parts'),
|
||||
url(r'^attachments/', views.BuildDetail.as_view(template_name='build/attachments.html'), name='build-attachments'),
|
||||
url(r'^output/', views.BuildDetail.as_view(template_name='build/build_output.html'), name='build-output'),
|
||||
|
@ -618,6 +618,7 @@ class BuildDetail(DetailView):
|
||||
|
||||
ctx['bom_price'] = build.part.get_price_info(build.quantity, buy=False)
|
||||
ctx['BuildStatus'] = BuildStatus
|
||||
ctx['sub_build_count'] = build.sub_build_count()
|
||||
|
||||
return ctx
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user