mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Remove outdated forms / views for stock item tracking (#3122)
* Remove outdated forms / views for stock item tracking - No longer used anywhere - Manual stock tracking entries are no longer supported anyway * Futher cleanup: - Delete unused template - Remove URL which pointed to a nonexistent template - Remove button for manually adding stock tracking entries
This commit is contained in:
parent
4b3f77763d
commit
ebca787f71
@ -2,7 +2,7 @@
|
||||
|
||||
from InvenTree.forms import HelperForm
|
||||
|
||||
from .models import StockItem, StockItemTracking
|
||||
from .models import StockItem
|
||||
|
||||
|
||||
class ConvertStockItemForm(HelperForm):
|
||||
@ -18,19 +18,3 @@ class ConvertStockItemForm(HelperForm):
|
||||
fields = [
|
||||
'part'
|
||||
]
|
||||
|
||||
|
||||
class TrackingEntryForm(HelperForm):
|
||||
"""Form for creating / editing a StockItemTracking object.
|
||||
|
||||
Note: 2021-05-11 - This form is not currently used - should delete?
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
"""Metaclass options."""
|
||||
|
||||
model = StockItemTracking
|
||||
|
||||
fields = [
|
||||
'notes',
|
||||
]
|
||||
|
@ -17,11 +17,6 @@
|
||||
<h4>{% trans "Stock Tracking Information" %}</h4>
|
||||
{% include "spacer.html" %}
|
||||
<div class='btn-group' role='group'>
|
||||
{% if user_owns_item and roles.stock.change and not item.is_building %}
|
||||
<button class='btn btn-success' type='button' title='New tracking entry' id='new-entry'>
|
||||
<span class='fas fa-plus-circle'></span> {% trans "New Entry" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -315,15 +310,6 @@
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
$("#new-entry").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'stock-tracking-create' item.id %}",
|
||||
{
|
||||
reload: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
loadStockTrackingTable($("#track-table"), {
|
||||
params: {
|
||||
ordering: '-date',
|
||||
|
@ -1,9 +0,0 @@
|
||||
{% extends "modal_delete_form.html" %}
|
||||
|
||||
{% block pre_form_content %}
|
||||
|
||||
<div class='alert alert-danger alert-block'>
|
||||
{% trans "Are you sure you want to delete this stock tracking entry?" %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -10,7 +10,7 @@ location_urls = [
|
||||
re_path(r'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'),
|
||||
re_path(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'),
|
||||
|
||||
# Anything else
|
||||
# Anything else - direct to the location detail view
|
||||
re_path('^.*$', views.StockLocationDetail.as_view(), name='stock-location-detail'),
|
||||
])),
|
||||
|
||||
@ -22,30 +22,17 @@ stock_item_detail_urls = [
|
||||
re_path(r'^qr_code/', views.StockItemQRCode.as_view(), name='stock-item-qr'),
|
||||
re_path(r'^delete_test_data/', views.StockItemDeleteTestData.as_view(), name='stock-item-delete-test-data'),
|
||||
|
||||
re_path(r'^add_tracking/', views.StockItemTrackingCreate.as_view(), name='stock-tracking-create'),
|
||||
|
||||
# Anything else - direct to the item detail view
|
||||
re_path('^.*$', views.StockItemDetail.as_view(), name='stock-item-detail'),
|
||||
]
|
||||
|
||||
stock_tracking_urls = [
|
||||
|
||||
# edit
|
||||
re_path(r'^(?P<pk>\d+)/edit/', views.StockItemTrackingEdit.as_view(), name='stock-tracking-edit'),
|
||||
|
||||
# delete
|
||||
re_path(r'^(?P<pk>\d+)/delete', views.StockItemTrackingDelete.as_view(), name='stock-tracking-delete'),
|
||||
]
|
||||
|
||||
stock_urls = [
|
||||
# Stock location
|
||||
re_path(r'^location/', include(location_urls)),
|
||||
|
||||
re_path(r'^track/', include(stock_tracking_urls)),
|
||||
|
||||
# Individual stock items
|
||||
re_path(r'^item/(?P<pk>\d+)/', include(stock_item_detail_urls)),
|
||||
|
||||
re_path(r'^sublocations/', views.StockIndex.as_view(template_name='stock/sublocation.html'), name='stock-sublocations'),
|
||||
|
||||
# Default to the stock index page
|
||||
re_path(r'^.*$', views.StockIndex.as_view(), name='stock-index'),
|
||||
]
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""Django views for interacting with Stock app."""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -10,12 +8,12 @@ from django.views.generic import DetailView, ListView
|
||||
import common.settings
|
||||
from InvenTree.forms import ConfirmForm
|
||||
from InvenTree.helpers import str2bool
|
||||
from InvenTree.views import (AjaxCreateView, AjaxDeleteView, AjaxUpdateView,
|
||||
from InvenTree.views import (AjaxDeleteView, AjaxUpdateView,
|
||||
InvenTreeRoleMixin, QRCodeView)
|
||||
from plugin.views import InvenTreePluginViewMixin
|
||||
|
||||
from . import forms as StockForms
|
||||
from .models import StockItem, StockItemTracking, StockLocation
|
||||
from .models import StockItem, StockLocation
|
||||
|
||||
|
||||
class StockIndex(InvenTreeRoleMixin, InvenTreePluginViewMixin, ListView):
|
||||
@ -229,65 +227,3 @@ class StockItemDelete(AjaxDeleteView):
|
||||
ajax_template_name = 'stock/item_delete.html'
|
||||
context_object_name = 'item'
|
||||
ajax_form_title = _('Delete Stock Item')
|
||||
|
||||
|
||||
class StockItemTrackingDelete(AjaxDeleteView):
|
||||
"""View to delete a StockItemTracking object.
|
||||
|
||||
Presents a deletion confirmation form to the user
|
||||
"""
|
||||
|
||||
model = StockItemTracking
|
||||
ajax_template_name = 'stock/tracking_delete.html'
|
||||
ajax_form_title = _('Delete Stock Tracking Entry')
|
||||
|
||||
|
||||
class StockItemTrackingEdit(AjaxUpdateView):
|
||||
"""View for editing a StockItemTracking object."""
|
||||
|
||||
model = StockItemTracking
|
||||
ajax_form_title = _('Edit Stock Tracking Entry')
|
||||
form_class = StockForms.TrackingEntryForm
|
||||
|
||||
|
||||
class StockItemTrackingCreate(AjaxCreateView):
|
||||
"""View for creating a new StockItemTracking object."""
|
||||
|
||||
model = StockItemTracking
|
||||
ajax_form_title = _("Add Stock Tracking Entry")
|
||||
form_class = StockForms.TrackingEntryForm
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Create StockItemTracking object."""
|
||||
self.request = request
|
||||
self.form = self.get_form()
|
||||
|
||||
valid = False
|
||||
|
||||
if self.form.is_valid():
|
||||
stock_id = self.kwargs['pk']
|
||||
|
||||
if stock_id:
|
||||
try:
|
||||
stock_item = StockItem.objects.get(id=stock_id)
|
||||
|
||||
# Save new tracking information
|
||||
tracking = self.form.save(commit=False)
|
||||
tracking.item = stock_item
|
||||
tracking.user = self.request.user
|
||||
tracking.quantity = stock_item.quantity
|
||||
tracking.date = datetime.now().date()
|
||||
tracking.system = False
|
||||
|
||||
tracking.save()
|
||||
|
||||
valid = True
|
||||
|
||||
except (StockItem.DoesNotExist, ValueError):
|
||||
pass
|
||||
|
||||
data = {
|
||||
'form_valid': valid
|
||||
}
|
||||
|
||||
return self.renderJsonResponse(request, self.form, data=data)
|
||||
|
Loading…
Reference in New Issue
Block a user