mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Remove some now unused forms / views / etc
This commit is contained in:
parent
5177b7f836
commit
802ff35cf3
@ -470,9 +470,9 @@ stock_api_urls = [
|
||||
|
||||
url(r'location/(?P<pk>\d+)/', include(location_endpoints)),
|
||||
|
||||
url(r'stocktake/?', StockStocktake.as_view(), name='api-stock-stocktake'),
|
||||
|
||||
url(r'move/?', StockMove.as_view(), name='api-stock-move'),
|
||||
# These JSON endpoints have been replaced (for now) with server-side form rendering - 02/06/2019
|
||||
# url(r'stocktake/?', StockStocktake.as_view(), name='api-stock-stocktake'),
|
||||
# url(r'move/?', StockMove.as_view(), name='api-stock-move'),
|
||||
|
||||
url(r'track/?', StockTrackingList.as_view(), name='api-stock-track'),
|
||||
|
||||
|
@ -42,20 +42,16 @@ class CreateStockItemForm(HelperForm):
|
||||
]
|
||||
|
||||
|
||||
class MoveStockItemForm(HelperForm):
|
||||
""" Form for moving a StockItem to a new location """
|
||||
|
||||
note = forms.CharField(label='Notes', required=True, help_text='Add note (required)')
|
||||
|
||||
class Meta:
|
||||
model = StockItem
|
||||
|
||||
fields = [
|
||||
'location',
|
||||
'note'
|
||||
]
|
||||
|
||||
class AdjustStockForm(forms.ModelForm):
|
||||
""" Form for performing simple stock adjustments.
|
||||
|
||||
- Add stock
|
||||
- Remove stock
|
||||
- Count stock
|
||||
- Move stock
|
||||
|
||||
This form is used for managing stock adjuments for single or multiple stock items.
|
||||
"""
|
||||
|
||||
def get_location_choices(self):
|
||||
locs = StockLocation.objects.all()
|
||||
@ -88,16 +84,6 @@ class AdjustStockForm(forms.ModelForm):
|
||||
]
|
||||
|
||||
|
||||
class StocktakeForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = StockItem
|
||||
|
||||
fields = [
|
||||
'quantity',
|
||||
]
|
||||
|
||||
|
||||
class EditStockItemForm(HelperForm):
|
||||
""" Form for editing a StockItem object.
|
||||
Note that not all fields can be edited here (even if they can be specified during creation.
|
||||
|
@ -22,11 +22,13 @@
|
||||
<ul class="dropdown-menu">
|
||||
{% if item.in_stock %}
|
||||
<li><a href="#" id='stock-edit' title='Edit stock item'>Edit stock item</a></li>
|
||||
<li><a href="#" id='stock-move' title='Move stock item'>Move stock item</a></li>
|
||||
<hr>
|
||||
<li><a href='#' id='stock-add' title='Add stock'>Add to stock</a></li>
|
||||
<li><a href='#' id='stock-remove' title='Remove stock'>Take from stock</a></li>
|
||||
<li><a href='#' id='stock-remove' title='Take stock'>Take from stock</a></li>
|
||||
<li><a href='#' id='stock-stocktake' title='Count stock'>Stocktake</a></li>
|
||||
<li><a href="#" id='stock-move' title='Move stock'>Move stock item</a></li>
|
||||
{% endif %}
|
||||
<hr>
|
||||
<li><a href="#" id='stock-delete' title='Delete stock item'>Delete stock item</a></li>
|
||||
</div>
|
||||
</div>
|
||||
@ -155,40 +157,33 @@
|
||||
});
|
||||
|
||||
{% if item.in_stock %}
|
||||
$("#stock-move").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'stock-item-move' item.id %}",
|
||||
{
|
||||
reload: true,
|
||||
submit_text: "Move"
|
||||
});
|
||||
});
|
||||
|
||||
function itemAdjust(action) {
|
||||
adjustStock({
|
||||
query: {
|
||||
pk: {{ item.id }},
|
||||
},
|
||||
action: action,
|
||||
success: function() {
|
||||
location.reload();
|
||||
launchModalForm("/stock/adjust/",
|
||||
{
|
||||
data: {
|
||||
action: action,
|
||||
item: {{ item.id }},
|
||||
},
|
||||
reload: true,
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
$("#stock-move").click(function() {
|
||||
itemAdjust("move");
|
||||
});
|
||||
|
||||
$("#stock-stocktake").click(function() {
|
||||
itemAdjust('stocktake');
|
||||
return false;
|
||||
itemAdjust('count');
|
||||
});
|
||||
|
||||
$('#stock-remove').click(function() {
|
||||
itemAdjust('remove');
|
||||
return false;
|
||||
itemAdjust('take');
|
||||
});
|
||||
|
||||
$('#stock-add').click(function() {
|
||||
itemAdjust('add');
|
||||
return false;
|
||||
});
|
||||
|
||||
{% endif %}
|
||||
|
@ -19,8 +19,6 @@ 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(r'^stocktake/?', views.StockItemStocktake.as_view(), name='stock-item-stocktake'),
|
||||
url(r'^qr_code/?', views.StockItemQRCode.as_view(), name='stock-item-qr'),
|
||||
|
||||
url('^.*$', views.StockItemDetail.as_view(), name='stock-item-detail'),
|
||||
|
@ -24,9 +24,6 @@ from .models import StockItem, StockLocation, StockItemTracking
|
||||
from .forms import EditStockLocationForm
|
||||
from .forms import CreateStockItemForm
|
||||
from .forms import EditStockItemForm
|
||||
from .forms import MoveStockItemForm
|
||||
from .forms import StocktakeForm
|
||||
from .forms import MoveStockItemForm
|
||||
from .forms import AdjustStockForm
|
||||
|
||||
|
||||
@ -583,76 +580,6 @@ class StockItemDelete(AjaxDeleteView):
|
||||
ajax_form_title = 'Delete Stock Item'
|
||||
|
||||
|
||||
class StockItemMove(AjaxUpdateView):
|
||||
"""
|
||||
View to move a StockItem from one location to another
|
||||
Performs some data validation to prevent illogical stock moves
|
||||
"""
|
||||
|
||||
model = StockItem
|
||||
ajax_template_name = 'modal_form.html'
|
||||
context_object_name = 'item'
|
||||
ajax_form_title = 'Move Stock Item'
|
||||
form_class = MoveStockItemForm
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = self.form_class(request.POST, instance=self.get_object())
|
||||
|
||||
if form.is_valid():
|
||||
|
||||
obj = self.get_object()
|
||||
|
||||
try:
|
||||
loc_id = form['location'].value()
|
||||
|
||||
if loc_id:
|
||||
loc = StockLocation.objects.get(pk=form['location'].value())
|
||||
if str(loc.pk) == str(obj.pk):
|
||||
form.errors['location'] = ['Item is already in this location']
|
||||
else:
|
||||
obj.move(loc, form['note'].value(), request.user)
|
||||
else:
|
||||
form.errors['location'] = ['Cannot move to an empty location']
|
||||
|
||||
except StockLocation.DoesNotExist:
|
||||
form.errors['location'] = ['Location does not exist']
|
||||
|
||||
data = {
|
||||
'form_valid': form.is_valid() and len(form.errors) == 0,
|
||||
}
|
||||
|
||||
return self.renderJsonResponse(request, form, data)
|
||||
|
||||
|
||||
class StockItemStocktake(AjaxUpdateView):
|
||||
"""
|
||||
View to perform stocktake on a single StockItem
|
||||
Updates the quantity, which will also create a new StockItemTracking item
|
||||
"""
|
||||
|
||||
model = StockItem
|
||||
template_name = 'modal_form.html'
|
||||
context_object_name = 'item'
|
||||
ajax_form_title = 'Item stocktake'
|
||||
form_class = StocktakeForm
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
||||
form = self.form_class(request.POST, instance=self.get_object())
|
||||
|
||||
if form.is_valid():
|
||||
|
||||
obj = self.get_object()
|
||||
|
||||
obj.stocktake(form.data['quantity'], request.user)
|
||||
|
||||
data = {
|
||||
'form_valid': form.is_valid()
|
||||
}
|
||||
|
||||
return self.renderJsonResponse(request, form, data)
|
||||
|
||||
|
||||
class StockTrackingIndex(ListView):
|
||||
"""
|
||||
StockTrackingIndex provides a page to display StockItemTracking objects
|
||||
|
Loading…
Reference in New Issue
Block a user