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

View File

@ -10,7 +10,25 @@
<hr>
<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>
{% endblock %}

View File

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

View File

@ -95,6 +95,9 @@
<div class='container-fluid'>
<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>
</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 () {
launchDeleteForm("#modal-delete",
"{% url 'stock-item-delete' item.id %}",

View File

@ -14,7 +14,7 @@ stock_location_detail_urls = [
stock_item_detail_urls = [
url(r'^edit/?', views.StockItemEdit.as_view(), name='stock-item-edit'),
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'),
]

View File

@ -11,8 +11,9 @@ from part.models import Part
from .models import StockItem, StockLocation
from .forms import EditStockLocationForm
from .forms import CreateStockItemForm
from .forms import EditStockItemForm
from .forms import MoveStockItemForm
class StockIndex(ListView):
model = StockItem
@ -84,7 +85,7 @@ class StockLocationCreate(AjaxCreateView):
class StockItemCreate(AjaxCreateView):
model = StockItem
form_class = EditStockItemForm
form_class = CreateStockItemForm
template_name = 'stock/item_create.html'
context_object_name = 'item'
ajax_template_name = 'modal_form.html'
@ -123,3 +124,14 @@ class StockItemDelete(AjaxDeleteView):
template_name = 'stock/item_delete.html'
context_object_name = '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