diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py index 87e042f4f3..227109c46c 100644 --- a/InvenTree/order/forms.py +++ b/InvenTree/order/forms.py @@ -115,23 +115,6 @@ class AllocateSerialsToSalesOrderForm(forms.Form): ] -class CreateSalesOrderAllocationForm(HelperForm): - """ - Form for creating a SalesOrderAllocation item. - """ - - quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5, label=_('Quantity')) - - class Meta: - model = SalesOrderAllocation - - fields = [ - 'line', - 'item', - 'quantity', - ] - - class EditSalesOrderAllocationForm(HelperForm): """ Form for editing a SalesOrderAllocation item diff --git a/InvenTree/order/urls.py b/InvenTree/order/urls.py index 5cdcd3f18d..37433e02f0 100644 --- a/InvenTree/order/urls.py +++ b/InvenTree/order/urls.py @@ -43,7 +43,6 @@ sales_order_detail_urls = [ sales_order_urls = [ # URLs for sales order allocations url(r'^allocation/', include([ - url(r'^new/', views.SalesOrderAllocationCreate.as_view(), name='so-allocation-create'), url(r'^assign-serials/', views.SalesOrderAssignSerials.as_view(), name='so-assign-serials'), ])), diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 5d1a4aed76..5bb6d161b6 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -29,7 +29,6 @@ from company.models import Company, SupplierPart # ManufacturerPart from stock.models import StockItem from part.models import Part -from common.models import InvenTreeSetting from common.forms import UploadFileForm, MatchFieldForm from common.views import FileManagementFormView from common.files import FileManager @@ -37,7 +36,7 @@ from common.files import FileManager from . import forms as order_forms from part.views import PartPricing -from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView +from InvenTree.views import AjaxView, AjaxUpdateView from InvenTree.helpers import DownloadFile, str2bool from InvenTree.helpers import extract_serial_numbers from InvenTree.views import InvenTreeRoleMixin @@ -976,81 +975,6 @@ class SalesOrderAssignSerials(AjaxView, FormMixin): ) -class SalesOrderAllocationCreate(AjaxCreateView): - """ View for creating a new SalesOrderAllocation """ - - model = SalesOrderAllocation - form_class = order_forms.CreateSalesOrderAllocationForm - ajax_form_title = _('Allocate Stock to Order') - - def get_initial(self): - initials = super().get_initial().copy() - - line_id = self.request.GET.get('line', None) - - if line_id is not None: - line = SalesOrderLineItem.objects.get(pk=line_id) - - initials['line'] = line - - # Search for matching stock items, pre-fill if there is only one - items = StockItem.objects.filter(part=line.part) - - quantity = line.quantity - line.allocated_quantity() - - if quantity < 0: - quantity = 0 - - if items.count() == 1: - item = items.first() - initials['item'] = item - - # Reduce the quantity IF there is not enough stock - qmax = item.quantity - item.allocation_count() - - if qmax < quantity: - quantity = qmax - - initials['quantity'] = quantity - - return initials - - def get_form(self): - - form = super().get_form() - - line_id = form['line'].value() - - # If a line item has been specified, reduce the queryset for the stockitem accordingly - try: - line = SalesOrderLineItem.objects.get(pk=line_id) - - # Construct a queryset for allowable stock items - queryset = StockItem.objects.filter(StockItem.IN_STOCK_FILTER) - - # Ensure the part reference matches - queryset = queryset.filter(part=line.part) - - # Exclude StockItem which are already allocated to this order - allocated = [allocation.item.pk for allocation in line.allocations.all()] - - queryset = queryset.exclude(pk__in=allocated) - - # Exclude stock items which have expired - if not InvenTreeSetting.get_setting('STOCK_ALLOW_EXPIRED_SALE'): - queryset = queryset.exclude(StockItem.EXPIRED_FILTER) - - form.fields['item'].queryset = queryset - - # Hide the 'line' field - form.fields['line'].widget = HiddenInput() - - except (ValueError, SalesOrderLineItem.DoesNotExist): - pass - - return form - - class LineItemPricing(PartPricing): """ View for inspecting part pricing information """ diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 34045bda43..d848f0e6b9 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -6,8 +6,6 @@ JSON API for the Stock app from __future__ import unicode_literals from datetime import datetime, timedelta -from django.db.models import query -from django.db.models.query import QuerySet from django.utils.translation import ugettext_lazy as _