2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

Add ability to move a stock item

This commit is contained in:
Oliver
2018-04-30 01:00:18 +10:00
parent bee760d184
commit d68b51e007
5 changed files with 48 additions and 4 deletions
InvenTree
build
templates
stock

@ -10,7 +10,25 @@
<hr> <hr>
<table class='table table-striped' id='part-table'> <table class='table table-striped' id='part-table'>
<thead>
<tr>
<th>Part</th>
<th>Source</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
{% for item in build.part.bom_items.all %}
<tr>
<td colspan='3'><b><i>{{ item.sub_part.name }}</b></i></td>
</tr>
<tr>
<td></td>
<td><i>Select...</i></td>
<td></td>
</tr>
{% endfor %}
</tbody>
</table> </table>
{% endblock %} {% endblock %}

@ -75,6 +75,7 @@ class StockList(generics.ListCreateAPIView):
'location', 'location',
'supplier_part', 'supplier_part',
'customer', 'customer',
'belongs_to',
'status', 'status',
] ]

@ -95,6 +95,9 @@
<div class='container-fluid'> <div class='container-fluid'>
<button class='btn btn-info' id='edit-item'>Edit Stock Item</button> <button class='btn btn-info' id='edit-item'>Edit Stock Item</button>
{% if item.in_stock %}
<button class='btn btn-primary' id='move-item'>Move Stock Item</button>
{% endif %}
<button class='btn btn-danger' id='delete-item'>Delete Stock Item</button> <button class='btn btn-danger' id='delete-item'>Delete Stock Item</button>
</div> </div>
@ -116,6 +119,16 @@
}); });
}); });
{% if item.in_stock %}
$("#move-item").click(function() {
launchModalForm("#modal-form",
"{% url 'stock-item-move' item.id %}",
{
reload: true,
});
});
{% endif %}
$("#delete-item").click(function () { $("#delete-item").click(function () {
launchDeleteForm("#modal-delete", launchDeleteForm("#modal-delete",
"{% url 'stock-item-delete' item.id %}", "{% url 'stock-item-delete' item.id %}",

@ -14,7 +14,7 @@ stock_location_detail_urls = [
stock_item_detail_urls = [ stock_item_detail_urls = [
url(r'^edit/?', views.StockItemEdit.as_view(), name='stock-item-edit'), url(r'^edit/?', views.StockItemEdit.as_view(), name='stock-item-edit'),
url(r'^delete/?', views.StockItemDelete.as_view(), name='stock-item-delete'), url(r'^delete/?', views.StockItemDelete.as_view(), name='stock-item-delete'),
url(r'^move/?', views.StockItemMove.as_view(), name='stock-item-move'),
url('^.*$', views.StockItemDetail.as_view(), name='stock-item-detail'), url('^.*$', views.StockItemDetail.as_view(), name='stock-item-detail'),
] ]

@ -11,8 +11,9 @@ from part.models import Part
from .models import StockItem, StockLocation from .models import StockItem, StockLocation
from .forms import EditStockLocationForm from .forms import EditStockLocationForm
from .forms import CreateStockItemForm
from .forms import EditStockItemForm from .forms import EditStockItemForm
from .forms import MoveStockItemForm
class StockIndex(ListView): class StockIndex(ListView):
model = StockItem model = StockItem
@ -84,7 +85,7 @@ class StockLocationCreate(AjaxCreateView):
class StockItemCreate(AjaxCreateView): class StockItemCreate(AjaxCreateView):
model = StockItem model = StockItem
form_class = EditStockItemForm form_class = CreateStockItemForm
template_name = 'stock/item_create.html' template_name = 'stock/item_create.html'
context_object_name = 'item' context_object_name = 'item'
ajax_template_name = 'modal_form.html' ajax_template_name = 'modal_form.html'
@ -123,3 +124,14 @@ class StockItemDelete(AjaxDeleteView):
template_name = 'stock/item_delete.html' template_name = 'stock/item_delete.html'
context_object_name = 'item' context_object_name = 'item'
ajax_form_title = 'Delete Stock Item' ajax_form_title = 'Delete Stock Item'
class StockItemMove(AjaxUpdateView):
model = StockItem
template_name = 'modal_form.html'
context_object_name = 'item'
ajax_form_title = 'Move Stock Item'
ajax_submit_text = 'Move'
form_class = MoveStockItemForm