Do not enforce serialization when creating a stock item

This commit is contained in:
Oliver Walters 2019-08-28 19:56:35 +10:00
parent 614363fa03
commit 88b90281f5
2 changed files with 42 additions and 37 deletions

View File

@ -7,6 +7,7 @@ from __future__ import unicode_literals
from django import forms
from django.forms.utils import ErrorDict
from django.utils.translation import ugettext as _
from InvenTree.forms import HelperForm
from .models import StockLocation, StockItem, StockItemTracking
@ -27,7 +28,7 @@ class EditStockLocationForm(HelperForm):
class CreateStockItemForm(HelperForm):
""" Form for creating a new StockItem """
serial_numbers = forms.CharField(label='Serial numbers', required=False, help_text='Enter unique serial numbers')
serial_numbers = forms.CharField(label='Serial numbers', required=False, help_text=_('Enter unique serial numbers (or leave blank)'))
class Meta:
model = StockItem

View File

@ -593,6 +593,10 @@ class StockItemCreate(AjaxCreateView):
if part.trackable:
sn = request.POST.get('serial_numbers', '')
sn = str(sn).strip()
# If user has specified a range of serial numbers
if len(sn) > 0:
try:
serials = ExtractSerialNumbers(sn, quantity)