+
{% for bom_item in bom_items.all %}
{% include "build/allocation_item.html" with item=bom_item build=build collapse_id=bom_item.id %}
{% endfor %}
diff --git a/InvenTree/build/templates/build/allocation_item.html b/InvenTree/build/templates/build/allocation_item.html
index 94e9e043a2..920012e953 100644
--- a/InvenTree/build/templates/build/allocation_item.html
+++ b/InvenTree/build/templates/build/allocation_item.html
@@ -3,33 +3,30 @@
{% load static %}
{% load inventree_extras %}
+{% block collapse_panel_setup %}class='panel part-allocation' id='allocation-panel-{{ item.sub_part.id }}'{% endblock %}
+
{% block collapse_title %}
-
0
+
+ {{ item.sub_part.available_stock }}
+ {% multiply build.quantity item.quantity %}
+
+
+
{% part_allocation_count build item.sub_part %}
- Allocate Parts
+ Allocate
{% endblock %}
diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html
new file mode 100644
index 0000000000..620db18df7
--- /dev/null
+++ b/InvenTree/build/templates/build/build_base.html
@@ -0,0 +1,102 @@
+{% extends "base.html" %}
+
+{% load static %}
+
+{% block page_title %}
+InvenTree | Build - {{ build }}
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+{% block details %}
+
+{% endblock %}
+
+
+
+{% include "modals.html" %}
+
+{% endblock %}
+
+{% block js_ready %}
+
+ $("#build-edit").click(function () {
+ launchModalForm("{% url 'build-edit' build.id %}",
+ {
+ reload: true
+ });
+ });
+
+ $("#build-cancel").click(function() {
+ launchModalForm("{% url 'build-cancel' build.id %}",
+ {
+ reload: true,
+ submit_text: "Cancel Build",
+ });
+ });
+
+ $("#build-complete").on('click', function() {
+ launchModalForm(
+ "{% url 'build-complete' build.id %}",
+ {
+ reload: true,
+ submit_text: "Complete Build",
+ }
+ );
+ });
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/build/templates/build/create_build_item.html b/InvenTree/build/templates/build/create_build_item.html
new file mode 100644
index 0000000000..c08b987d36
--- /dev/null
+++ b/InvenTree/build/templates/build/create_build_item.html
@@ -0,0 +1,9 @@
+{% extends "modal_form.html" %}
+
+{% block pre_form_content %}
+{% if no_stock %}
+
+ No stock available for {{ part }}
+
+{% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html
index a46a146d77..6b916d08bf 100644
--- a/InvenTree/build/templates/build/detail.html
+++ b/InvenTree/build/templates/build/detail.html
@@ -1,39 +1,11 @@
-{% extends "base.html" %}
+{% extends "build/build_base.html" %}
{% load static %}
-{% block page_title %}
-InvenTree | Build - {{ build }}
-{% endblock %}
+{% block details %}
-{% block content %}
+{% include "build/tabs.html" with tab='details' %}
-
-
-
Build Details
-
{{ build.title }} {% include "build_status.html" with build=build %}
-
Building {{ build.quantity }} × {{ build.part.full_name }}
-
-
-
+
Build Details
@@ -88,67 +60,13 @@ InvenTree | Build - {{ build }}
Completed {{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }} {% endif %}
{% endif %}
+
+
{% if build.notes %}
-
- Notes {{ build.notes }}
-
-{% endif %}
-
-
-{% if build.is_active %}
-
Required Parts
-
-
-
- Part
- Required
- Available
- Allocated
-
-
-
- {% for item in build.required_parts %}
-
- {{ item.part.full_name }}
- {{ item.quantity }}
- {{ item.part.total_stock }}
- {{ item.allocated }}
-
- {% endfor %}
-
-
-
+
+
Notes
+
{{ build.notes }}
+
{% endif %}
-{% include 'modals.html' %}
-
-{% endblock %}
-
-{% block js_ready %}
-{{ block.super }}
- $("#build-edit").click(function () {
- launchModalForm("{% url 'build-edit' build.id %}",
- {
- reload: true
- });
- });
-
- $("#build-cancel").click(function() {
- launchModalForm("{% url 'build-cancel' build.id %}",
- {
- reload: true,
- submit_text: "Cancel Build",
- });
- });
-
- $("#build-complete").on('click', function() {
- launchModalForm(
- "{% url 'build-complete' build.id %}",
- {
- reload: true,
- submit_text: "Complete Build",
- }
- );
- });
-
{% endblock %}
diff --git a/InvenTree/build/templates/build/required.html b/InvenTree/build/templates/build/required.html
new file mode 100644
index 0000000000..831d8d03b3
--- /dev/null
+++ b/InvenTree/build/templates/build/required.html
@@ -0,0 +1,36 @@
+{% extends "build/build_base.html" %}
+{% load static %}
+
+{% block details %}
+
+{% include "build/tabs.html" with tab='required' %}
+
+
Required Parts
+
+
+
+ Part
+ Available
+ Required
+ Allocated
+
+
+
+ {% for item in build.required_parts %}
+
+
+
+
+
+
+ {{ item.part.full_name }}
+
+ {{ item.part.total_stock }}
+ {{ item.quantity }}
+ {{ item.allocated }}
+
+ {% endfor %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/build/templates/build/tabs.html b/InvenTree/build/templates/build/tabs.html
new file mode 100644
index 0000000000..c52309b132
--- /dev/null
+++ b/InvenTree/build/templates/build/tabs.html
@@ -0,0 +1,13 @@
+
+
+
\ No newline at end of file
diff --git a/InvenTree/build/urls.py b/InvenTree/build/urls.py
index 3118bd6042..383e478494 100644
--- a/InvenTree/build/urls.py
+++ b/InvenTree/build/urls.py
@@ -24,6 +24,8 @@ build_detail_urls = [
url(r'^auto-allocate/?', views.BuildAutoAllocate.as_view(), name='build-auto-allocate'),
url(r'^unallocate/', views.BuildUnallocate.as_view(), name='build-unallocate'),
+ url(r'^required/', views.BuildDetail.as_view(template_name='build/required.html'), name='build-required'),
+
url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'),
]
diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py
index 7cef486d55..6f19c67754 100644
--- a/InvenTree/build/views.py
+++ b/InvenTree/build/views.py
@@ -355,9 +355,25 @@ class BuildItemCreate(AjaxCreateView):
model = BuildItem
form_class = forms.EditBuildItemForm
- ajax_template_name = 'modal_form.html'
+ ajax_template_name = 'build/create_build_item.html'
ajax_form_title = 'Allocate new Part'
+ part = None
+ available_stock = None
+
+ def get_context_data(self):
+ ctx = super(AjaxCreateView, self).get_context_data()
+
+ if self.part:
+ ctx['part'] = self.part
+
+ if self.available_stock:
+ ctx['stock'] = self.available_stock
+ else:
+ ctx['no_stock'] = True
+
+ return ctx
+
def get_form(self):
""" Create Form for making / editing new Part object """
@@ -375,7 +391,7 @@ class BuildItemCreate(AjaxCreateView):
if part_id:
try:
- Part.objects.get(pk=part_id)
+ self.part = Part.objects.get(pk=part_id)
query = form.fields['stock_item'].queryset
@@ -399,6 +415,8 @@ class BuildItemCreate(AjaxCreateView):
form.fields['stock_item'].queryset = query
stocks = query.all()
+ self.available_stock = stocks
+
# If there is only one item selected, select it
if len(stocks) == 1:
form.fields['stock_item'].initial = stocks[0].id
@@ -408,6 +426,7 @@ class BuildItemCreate(AjaxCreateView):
pass
except Part.DoesNotExist:
+ self.part = None
pass
return form
diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html
index 8b9561ea2e..68b89bf1b9 100644
--- a/InvenTree/part/templates/part/stock.html
+++ b/InvenTree/part/templates/part/stock.html
@@ -44,4 +44,29 @@
url: "{% url 'api-stock-list' %}",
});
+ $('#item-create').click(function () {
+ launchModalForm("{% url 'stock-item-create' %}", {
+ reload: true,
+ data: {
+ part: {{ part.id }}
+ },
+ secondary: [
+ {
+ field: 'part',
+ label: 'New Part',
+ title: 'Create New Part',
+ url: "{% url 'part-create' %}",
+ },
+ {
+ field: 'location',
+ label: 'New Location',
+ title: 'Create New Location',
+ url: "{% url 'stock-location-create' %}",
+ }
+ ]
+ });
+
+ return false;
+ });
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py
index c06854227c..b17c5bf9e8 100644
--- a/InvenTree/part/templatetags/inventree_extras.py
+++ b/InvenTree/part/templatetags/inventree_extras.py
@@ -14,6 +14,13 @@ def multiply(x, y, *args, **kwargs):
return x * y
+@register.simple_tag()
+def part_allocation_count(build, part, *args, **kwargs):
+ """ Return the total number of
allocated to """
+
+ return build.getAllocatedQuantity(part)
+
+
@register.simple_tag()
def inventree_version(*args, **kwargs):
""" Return InvenTree version string """
diff --git a/InvenTree/static/css/inventree.css b/InvenTree/static/css/inventree.css
index bca4560edf..59e7899891 100644
--- a/InvenTree/static/css/inventree.css
+++ b/InvenTree/static/css/inventree.css
@@ -14,7 +14,6 @@
color: #ffcc00;
}
-
/* CSS overrides for treeview */
.expand-icon {
font-size: 11px;
@@ -32,6 +31,14 @@
padding: 5px 10px;
}
+/* Extra label styles */
+
+.label-large {
+ padding: 5px;
+ margin: 3px;
+ font-size: 100%;
+}
+
/* Force select2 elements in modal forms to be full width */
.select-full-width {
width: 100%;
@@ -269,11 +276,12 @@
}
.panel-group .panel {
- border-radius: 8px;
+ border-radius: 2px;
}
.panel-heading {
padding: 5px 10px;
+ background-color: #fafafa;
}
.float-right {
@@ -291,16 +299,22 @@
transform: translate(-50%, -50%);
}
+.part-allocation {
+ padding: 3px 10px;
+ border: 1px solid #ccc;
+ border-radius: 2px;
+}
+
.part-allocation-pass {
- background: #dbf0db;
+ background-color: #dbf0db;
}
.part-allocation-underallocated {
- background: #f0dbdb;
+ background-color: #f0dbdb;
}
.part-allocation-overallocated {
- background: #ccf5ff;
+ background-color: #ccf5ff;
}
.glyphicon-refresh-animate {
diff --git a/InvenTree/static/script/inventree/build.js b/InvenTree/static/script/inventree/build.js
index c982cc254c..e3d1238e5e 100644
--- a/InvenTree/static/script/inventree/build.js
+++ b/InvenTree/static/script/inventree/build.js
@@ -56,7 +56,7 @@ function loadAllocationTable(table, part_id, part, url, required, button) {
launchModalForm(button.attr('url'), {
success: function() {
table.bootstrapTable('refresh');
- }
+ },
});
});
diff --git a/InvenTree/templates/build_status.html b/InvenTree/templates/build_status.html
index 3fc5f6086c..793e3ea231 100644
--- a/InvenTree/templates/build_status.html
+++ b/InvenTree/templates/build_status.html
@@ -1,11 +1,11 @@
{% if build.status == build.PENDING %}
-
+
{% elif build.status == build.ALLOCATED %}
-
+
{% elif build.status == build.CANCELLED %}
-
+
{% elif build.status == build.COMPLETE %}
-
+
{% endif %}
{{ build.get_status_display }}
\ No newline at end of file
diff --git a/InvenTree/templates/collapse.html b/InvenTree/templates/collapse.html
index 776c9cee35..5624f34094 100644
--- a/InvenTree/templates/collapse.html
+++ b/InvenTree/templates/collapse.html
@@ -2,7 +2,7 @@
{% endblock %}
-
+
diff --git a/InvenTree/templates/modal_form.html b/InvenTree/templates/modal_form.html
index 1a99fc09ff..1f5482f8d6 100644
--- a/InvenTree/templates/modal_form.html
+++ b/InvenTree/templates/modal_form.html
@@ -5,13 +5,13 @@
{% endif %}
{% if form.pre_form_warning %}
-
+
{{ form.pre_form_warning }}
{% endif %}
{% block non_field_error %}
{% if form.non_field_errors %}
-
+
Error Submitting Form:
{{ form.non_field_errors }}