diff --git a/InvenTree/build/forms.py b/InvenTree/build/forms.py
new file mode 100644
index 0000000000..0134a1e92b
--- /dev/null
+++ b/InvenTree/build/forms.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django import forms
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Submit
+
+from .models import Build
+
+
+class EditBuildForm(forms.ModelForm):
+
+ def __init__(self, *args, **kwargs):
+ super(EditBuildForm, self).__init__(*args, **kwargs)
+ self.helper = FormHelper()
+
+ self.helper.form_id = 'id-edit-part-form'
+ self.helper.form_class = 'blueForms'
+ self.helper.form_method = 'post'
+
+ self.helper.add_input(Submit('submit', 'Submit'))
+
+ class Meta:
+ model = Build
+ fields = [
+ 'title',
+ 'notes',
+ 'part',
+ 'batch',
+ 'quantity',
+ 'status',
+ 'completion_date',
+ ]
\ No newline at end of file
diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py
index ef4b495ced..ac9c26bdd8 100644
--- a/InvenTree/build/models.py
+++ b/InvenTree/build/models.py
@@ -14,6 +14,9 @@ class Build(models.Model):
Parts are then taken from stock
"""
+ def get_absolute_url(self):
+ return '/build/{pk}/'.format(pk=self.id)
+
# Build status codes
PENDING = 10 # Build is pending / active
HOLDING = 20 # Build is currently being held
diff --git a/InvenTree/build/templates/build/build_list.html b/InvenTree/build/templates/build/build_list.html
new file mode 100644
index 0000000000..5720235911
--- /dev/null
+++ b/InvenTree/build/templates/build/build_list.html
@@ -0,0 +1,9 @@
+
+{% for build in builds %}
+
+ {{ build.title }}
+ {{ build.part.name }}
+ {{ build.quantity }}
+ {% include "build_status.html" with build=build %}
+
+{% endfor %}
\ No newline at end of file
diff --git a/InvenTree/build/templates/build/create.html b/InvenTree/build/templates/build/create.html
new file mode 100644
index 0000000000..b53fc58fec
--- /dev/null
+++ b/InvenTree/build/templates/build/create.html
@@ -0,0 +1,5 @@
+{% extends "create_edit_obj.html" %}
+
+{% block obj_title %}
+Create a new build
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html
index 1ec5b4a8e3..f8500b0fe0 100644
--- a/InvenTree/build/templates/build/detail.html
+++ b/InvenTree/build/templates/build/detail.html
@@ -1,3 +1,41 @@
{% include "base.html" %}
-Build detail for Build No. {{ build.id }}.
\ No newline at end of file
+{% block content %}
+Build Details
+
+
+ Title {{ build.title }}
+
+
+ Part {{ build.part.name }}
+
+
+ Quantity {{ build.quantity }}
+
+{% if build.batch %}
+
+ Batch {{ build.batch }}
+
+{% endif %}
+
+ Status {% include "build_status.html" with build=build %}
+
+
+ Created {{ build.creation_date }}
+
+{% if batch.completion_date %}
+
+ Completed {{ build.creation_date }}
+
+{% endif %}
+{% if build.notes %}
+
+ Notes {{ build.notes }}
+
+{% endif %}
+
+
+
+
Edit Build
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/build/templates/build/index.html b/InvenTree/build/templates/build/index.html
index aaf722d8d1..b96be4313e 100644
--- a/InvenTree/build/templates/build/index.html
+++ b/InvenTree/build/templates/build/index.html
@@ -2,6 +2,33 @@
{% block content %}
-
Builds
+
Part Builds
+
+
+
+
+ Part
+ Quantity
+ Status
+
+
+{% if active|length > 0 %}
+Active Builds
+{% include "build/build_list.html" with builds=active %}
+{% endif %}
+
+{% if complete|length > 0 %}
+
+Completed Builds
+{% include "build/build_list.html" with builds=complete %}
+{% endif %}
+
+{% if cancelled|length > 0 %}
+
+Cancelled Builds
+{% include "build/build_list.html" with builds=cancelled.all %}
+{% endif %}
+
+
{% endblock %}
diff --git a/InvenTree/build/templates/build/update.html b/InvenTree/build/templates/build/update.html
new file mode 100644
index 0000000000..c5691d145f
--- /dev/null
+++ b/InvenTree/build/templates/build/update.html
@@ -0,0 +1,5 @@
+{% extends "create_edit_obj.html" %}
+
+{% block obj_title %}
+Edit build details
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/build/urls.py b/InvenTree/build/urls.py
index b3552ce5e9..f5a2192a43 100644
--- a/InvenTree/build/urls.py
+++ b/InvenTree/build/urls.py
@@ -4,12 +4,13 @@ from django.views.generic.base import RedirectView
from . import views
build_detail_urls = [
+ url(r'^edit/?', views.BuildUpdate.as_view(), name='build-edit'),
url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'),
]
build_urls = [
- # url(r'new/?', views.BuildCreate.as_view(), name='build-create'),
+ url(r'new/?', views.BuildCreate.as_view(), name='build-create'),
url(r'^(?P
\d+)/', include(build_detail_urls)),
diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py
index ae26c1f99b..64139b4a9f 100644
--- a/InvenTree/build/views.py
+++ b/InvenTree/build/views.py
@@ -7,16 +7,56 @@ from django.http import HttpResponseRedirect
from django.views.generic import DetailView, ListView
from django.views.generic.edit import UpdateView, DeleteView, CreateView
+from part.models import Part
from .models import Build
+from .forms import EditBuildForm
class BuildIndex(ListView):
model = Build
template_name = 'build/index.html'
context_object_name = 'builds'
+ def get_queryset(self):
+ return Build.objects.order_by('status', '-completion_date')
+
+ def get_context_data(self, **kwargs):
+
+ context = super(BuildIndex, self).get_context_data(**kwargs).copy()
+
+ context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, Build.HOLDING])
+
+ context['complete'] = self.get_queryset().filter(status=Build.COMPLETE)
+ context['cancelled'] = self.get_queryset().filter(status=Build.CANCELLED)
+
+ return context
+
class BuildDetail(DetailView):
model = Build
template_name = 'build/detail.html'
context_object_name = 'build'
+
+
+class BuildCreate(CreateView):
+ model = Build
+ template_name = 'build/create.html'
+ context_object_name = 'build'
+ form_class = EditBuildForm
+
+ def get_initial(self):
+ initials = super(BuildCreate, self).get_initial().copy()
+
+ part_id = self.request.GET.get('part', None)
+
+ if part_id:
+ initials['part'] = get_object_or_404(Part, pk=part_id)
+
+ return initials
+
+
+class BuildUpdate(UpdateView):
+ model = Build
+ form_class = EditBuildForm
+ context_object_name = 'build'
+ template_name = 'build/update.html'
diff --git a/InvenTree/part/templates/part/build_status.html b/InvenTree/part/templates/build_status.html
similarity index 100%
rename from InvenTree/part/templates/part/build_status.html
rename to InvenTree/part/templates/build_status.html
diff --git a/InvenTree/part/templates/navbar.html b/InvenTree/part/templates/navbar.html
index db8cae6aa7..70863e0291 100644
--- a/InvenTree/part/templates/navbar.html
+++ b/InvenTree/part/templates/navbar.html
@@ -6,9 +6,10 @@
\ No newline at end of file
diff --git a/InvenTree/part/templates/part/allocation.html b/InvenTree/part/templates/part/allocation.html
index 35b8426815..13760371e1 100644
--- a/InvenTree/part/templates/part/allocation.html
+++ b/InvenTree/part/templates/part/allocation.html
@@ -20,7 +20,7 @@
{{ build.title }}
{{ build.part.name }}
Quantity
- {% include "part/build_status.html" with build=build %}
+ {% include "build_status.html" with build=build %}
{% endfor %}
diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html
index 3aae16377f..9f816a2bf2 100644
--- a/InvenTree/part/templates/part/build.html
+++ b/InvenTree/part/templates/part/build.html
@@ -31,4 +31,7 @@
+
+
Start New Build
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/part/templates/part/build_list.html b/InvenTree/part/templates/part/build_list.html
index 8798323204..282997c147 100644
--- a/InvenTree/part/templates/part/build_list.html
+++ b/InvenTree/part/templates/part/build_list.html
@@ -3,7 +3,7 @@
{{ build.title }}
{{ build.quantity }}
- {% include "part/build_status.html" with build=build %}
+ {% include "build_status.html" with build=build %}
{% if build.completion_date %}{{ build.completion_date }}{% endif %}
diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html
index a9f66a76b9..eff277edfe 100644
--- a/InvenTree/part/templates/part/part_base.html
+++ b/InvenTree/part/templates/part/part_base.html
@@ -77,7 +77,7 @@
{% if part.allocation_count > part.total_stock %}
{{ part.allocation_count }}
{% else %}
- {{ part.allocation_count }} {{ part.total_stock }}
+ {{ part.allocation_count }}
{% endif %}
diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py
index c7defebaa3..b98c9fca1a 100644
--- a/InvenTree/stock/forms.py
+++ b/InvenTree/stock/forms.py
@@ -1,10 +1,12 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from .models import StockLocation, StockItem
-
class EditStockLocationForm(forms.ModelForm):
def __init__(self, *args, **kwargs):