diff --git a/InvenTree/part/templates/part/index.html b/InvenTree/part/templates/part/index.html
index 1a281b731a..73cc9f5eba 100644
--- a/InvenTree/part/templates/part/index.html
+++ b/InvenTree/part/templates/part/index.html
@@ -33,7 +33,11 @@ $(document).ready(function () {
$('#part-list').footable();
$("#create-cat").click(function() {
- launchModalForm("#modal-form", "{% url 'category-create' %}");
+ launchModalForm("#modal-form",
+ "{% url 'category-create' %}",
+ {
+ follow: true
+ });
});
$("#create-part").click(function() {
diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html
index 85f899fb38..d07f8cf2b6 100644
--- a/InvenTree/part/templates/part/stock.html
+++ b/InvenTree/part/templates/part/stock.html
@@ -1,25 +1,32 @@
{% extends "part/part_base.html" %}
-
+{% load static %}
{% block details %}
{% include 'part/tabs.html' with tab='stock' %}
Part Stock
-
+
-
- Add new Stock Item
-
+Add new Stock Item
+{% include 'modals.html' %}
+
+{% endblock %}
+
+{% block javascript %}
+
+
+
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py
index 36b1ba6cca..68e2c9b080 100644
--- a/InvenTree/stock/forms.py
+++ b/InvenTree/stock/forms.py
@@ -14,11 +14,7 @@ class EditStockLocationForm(forms.ModelForm):
super(EditStockLocationForm, 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'))
+ self.helper.form_tag = False
class Meta:
model = StockLocation
@@ -35,11 +31,7 @@ class EditStockItemForm(forms.ModelForm):
super(EditStockItemForm, 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'))
+ self.helper.form_tag = False
class Meta:
model = StockItem
diff --git a/InvenTree/stock/templates/stock/index.html b/InvenTree/stock/templates/stock/index.html
index 6af13b6744..08bc715f70 100644
--- a/InvenTree/stock/templates/stock/index.html
+++ b/InvenTree/stock/templates/stock/index.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
+{% load static %}
{% block content %}
{% include "stock/loc_link.html" with location=None %}
@@ -9,14 +9,65 @@
{% include "stock/location_list.html" with locations=locations %}
{% endif %}
-{% if items|length > 0 %}
-{% include "stock/stock_table.html" with items=items %}
-{% endif %}
+
+{% include 'modals.html' %}
+
+{% endblock %}
+
+{% block javascript %}
+
+
+
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html
index 65394d623d..cfc5708297 100644
--- a/InvenTree/stock/templates/stock/item.html
+++ b/InvenTree/stock/templates/stock/item.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
+{% load static %}
{% block content %}
{% include "stock/loc_link.html" with location=item.location %}
@@ -94,12 +94,38 @@
{% endif %}
+{% include 'modals.html' %}
+
+{% endblock %}
+
+{% block javascript %}
+
+
+
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/stock/templates/stock/item_delete.html b/InvenTree/stock/templates/stock/item_delete.html
index dfbac09c26..ff22da1d10 100644
--- a/InvenTree/stock/templates/stock/item_delete.html
+++ b/InvenTree/stock/templates/stock/item_delete.html
@@ -1,9 +1,5 @@
-{% extends "delete_obj.html" %}
-
-{% block del_title %}
Are you sure you want to delete this stock item?
-{% endblock %}
-{% block del_body %}
-This will remove {{ item.quantity }} units of '{{ item.part.name }}' from stock.
-{% endblock %}
\ No newline at end of file
+
+
+This will remove {{ item.quantity }} units of {{ item.part.name }} from stock.
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html
index 3367848306..b9716164b5 100644
--- a/InvenTree/stock/templates/stock/location.html
+++ b/InvenTree/stock/templates/stock/location.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
+{% load static %}
{% block content %}
{% include "stock/loc_link.html" with location=location %}
@@ -12,27 +12,70 @@
{% include "stock/location_list.html" with locations=location.children %}
{% endif %}
-{% if location.has_items %}
Stock Items
{% include "stock/stock_table.html" with items=location.items %}
-{% endif %}
-{% endblock %}
\ No newline at end of file
+{% include 'modals.html' %}
+
+{% endblock %}
+
+{% block javascript %}
+
+
+
+
+
+
+{% endblock %}
diff --git a/InvenTree/stock/templates/stock/location_delete.html b/InvenTree/stock/templates/stock/location_delete.html
index 5bdd5249f6..53cdf2cc27 100644
--- a/InvenTree/stock/templates/stock/location_delete.html
+++ b/InvenTree/stock/templates/stock/location_delete.html
@@ -1,10 +1,7 @@
-{% extends 'delete_obj.html' %}
-
-{% block del_title %}
Are you sure you want to delete stock location '{{ location.name }}'?
-{% endblock %}
-{% block del_body %}
+
+
{% if location.children.all|length > 0 %}
This location contains {{ location.children.all|length }} child locations.
If this location is deleted, these child locations will be moved to
@@ -37,5 +34,3 @@ If this location is deleted, these items will be moved to the top level 'Stock'
{% endfor %}
{% endif %}
-
-{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/stock/templates/stock/location_list.html b/InvenTree/stock/templates/stock/location_list.html
index 348ef61454..79e378ca37 100644
--- a/InvenTree/stock/templates/stock/location_list.html
+++ b/InvenTree/stock/templates/stock/location_list.html
@@ -1,5 +1,5 @@
\ No newline at end of file
diff --git a/InvenTree/stock/templates/stock/stock_table.html b/InvenTree/stock/templates/stock/stock_table.html
index b6e92e060f..044815fea1 100644
--- a/InvenTree/stock/templates/stock/stock_table.html
+++ b/InvenTree/stock/templates/stock/stock_table.html
@@ -1,11 +1,14 @@
-
+
+
Part
Stock
Status
Stocktake
-
+
+
+
{% for item in items.all %}
{{ item.part.name }}
@@ -15,4 +18,5 @@
Click
{% endfor %}
+
\ No newline at end of file
diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py
index 089953b16f..0022feab25 100644
--- a/InvenTree/stock/views.py
+++ b/InvenTree/stock/views.py
@@ -4,6 +4,8 @@ from django.http import HttpResponseRedirect
from django.views.generic import DetailView, ListView
from django.views.generic.edit import UpdateView, DeleteView, CreateView
+from InvenTree.views import AjaxUpdateView, AjaxDeleteView, AjaxCreateView
+
from part.models import Part
from .models import StockItem, StockLocation
@@ -14,18 +16,16 @@ from .forms import EditStockItemForm
class StockIndex(ListView):
model = StockItem
template_name = 'stock/index.html'
- context_obect_name = 'items'
- paginate_by = 50
-
- def get_queryset(self):
- return StockItem.objects.filter(location=None)
+ context_obect_name = 'locations'
def get_context_data(self, **kwargs):
context = super(StockIndex, self).get_context_data(**kwargs).copy()
+ # Return all top-level locations
locations = StockLocation.objects.filter(parent=None)
context['locations'] = locations
+ context['items'] = StockItem.objects.all()
return context
@@ -44,25 +44,31 @@ class StockItemDetail(DetailView):
model = StockItem
-class StockLocationEdit(UpdateView):
+class StockLocationEdit(AjaxUpdateView):
model = StockLocation
form_class = EditStockLocationForm
template_name = 'stock/location_edit.html'
context_object_name = 'location'
+ ajax_template_name = 'modal_form.html'
+ ajax_form_title = 'Edit Stock Location'
-class StockItemEdit(UpdateView):
+class StockItemEdit(AjaxUpdateView):
model = StockItem
form_class = EditStockItemForm
template_name = 'stock/item_edit.html'
context_object_name = 'item'
+ ajax_template_name = 'modal_form.html'
+ ajax_form_title = 'Edit Stock Item'
-class StockLocationCreate(CreateView):
+class StockLocationCreate(AjaxCreateView):
model = StockLocation
form_class = EditStockLocationForm
template_name = 'stock/location_create.html'
context_object_name = 'location'
+ ajax_template_name = 'modal_form.html'
+ ajax_form_title = 'Create new Stock Location'
def get_initial(self):
initials = super(StockLocationCreate, self).get_initial().copy()
@@ -75,11 +81,13 @@ class StockLocationCreate(CreateView):
return initials
-class StockItemCreate(CreateView):
+class StockItemCreate(AjaxCreateView):
model = StockItem
form_class = EditStockItemForm
template_name = 'stock/item_create.html'
context_object_name = 'item'
+ ajax_template_name = 'modal_form.html'
+ ajax_form_title = 'Create new Stock Item'
def get_initial(self):
initials = super(StockItemCreate, self).get_initial().copy()
@@ -100,27 +108,17 @@ class StockItemCreate(CreateView):
return initials
-class StockLocationDelete(DeleteView):
+class StockLocationDelete(AjaxDeleteView):
model = StockLocation
success_url = '/stock'
template_name = 'stock/location_delete.html'
context_object_name = 'location'
-
- def post(self, request, *args, **kwargs):
- if 'confirm' in request.POST:
- return super(StockLocationDelete, self).post(request, *args, **kwargs)
- else:
- return HttpResponseRedirect(self.get_object().get_absolute_url())
+ ajax_form_title = 'Delete Stock Location'
-class StockItemDelete(DeleteView):
+class StockItemDelete(AjaxDeleteView):
model = StockItem
success_url = '/stock/'
template_name = 'stock/item_delete.html'
context_object_name = 'item'
-
- def post(self, request, *args, **kwargs):
- if 'confirm' in request.POST:
- return super(StockItemDelete, self).post(request, *args, **kwargs)
- else:
- return HttpResponseRedirect(self.get_object().get_absolute_url())
+ ajax_form_title = 'Delete Stock Item'