mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
PEP fixes
This commit is contained in:
parent
a6ad263ee7
commit
8a99062704
@ -197,17 +197,12 @@ class BuildComplete(AjaxUpdateView):
|
||||
if not build.part.trackable:
|
||||
form.fields.pop('serial_numbers')
|
||||
else:
|
||||
sn = build.part.getNextSerialNumber()
|
||||
|
||||
if build.quantity > 1:
|
||||
sn = "{n}-{m}".format(
|
||||
n=str(sn),
|
||||
m=str(sn+build.quantity-1)
|
||||
)
|
||||
if build.quantity == 1:
|
||||
text = _('Next available serial number is')
|
||||
else:
|
||||
sn = str(sn)
|
||||
|
||||
form.field_placeholder['serial_numbers'] = sn
|
||||
text = _('Next available serial numbers are')
|
||||
|
||||
form.field_placeholder['serial_numbers'] = text + " " + build.part.getSerialNumberString(build.quantity)
|
||||
|
||||
form.rebuild_layout()
|
||||
|
||||
|
@ -8,9 +8,6 @@ from __future__ import unicode_literals
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from crispy_forms.layout import Field, Layout
|
||||
from crispy_forms.bootstrap import PrependedText
|
||||
|
||||
from mptt.fields import TreeNodeChoiceField
|
||||
|
||||
from InvenTree.forms import HelperForm
|
||||
|
@ -308,6 +308,24 @@ class Part(MPTTModel):
|
||||
else:
|
||||
return n + 1
|
||||
|
||||
def getSerialNumberString(self, quantity):
|
||||
"""
|
||||
Return a formatted string representing the next available serial numbers,
|
||||
given a certain quantity of items.
|
||||
"""
|
||||
|
||||
sn = self.getNextSerialNumber()
|
||||
|
||||
if quantity >= 2:
|
||||
sn = "{n}-{m}".format(
|
||||
n=sn,
|
||||
m=int(sn + quantity - 1)
|
||||
)
|
||||
else:
|
||||
sn = str(sn)
|
||||
|
||||
return sn
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
""" Format a 'full name' for this Part.
|
||||
|
@ -9,9 +9,6 @@ from django import forms
|
||||
from django.forms.utils import ErrorDict
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from crispy_forms.layout import Field, Layout
|
||||
from crispy_forms.bootstrap import PrependedText
|
||||
|
||||
from mptt.fields import TreeNodeChoiceField
|
||||
|
||||
from InvenTree.helpers import GetExportFormats
|
||||
@ -111,23 +108,7 @@ class SerializeStockForm(HelperForm):
|
||||
item = kwargs.pop('item', None)
|
||||
|
||||
if item:
|
||||
|
||||
# Pre-calculate what the serial numbers should be!
|
||||
sn = item.part.getNextSerialNumber()
|
||||
|
||||
if item.quantity >= 2:
|
||||
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
||||
else:
|
||||
sn = str(sn)
|
||||
|
||||
|
||||
self.field_placeholder = {
|
||||
'serial_numbers': sn
|
||||
}
|
||||
|
||||
self.field_prefix = {
|
||||
'serial_numbers': 'fa-hashtag',
|
||||
}
|
||||
self.field_placeholder['serial_numbers'] = item.part.getSerialNumberString(item.quantity)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
@ -308,7 +308,6 @@ class StockTest(TestCase):
|
||||
item.delete_on_deplete = True
|
||||
item.save()
|
||||
|
||||
|
||||
n = StockItem.objects.filter(part=25).count()
|
||||
|
||||
self.assertEqual(item.quantity, 10)
|
||||
|
@ -755,7 +755,7 @@ class StockItemSerialize(AjaxUpdateView):
|
||||
model = StockItem
|
||||
ajax_template_name = 'stock/item_serialize.html'
|
||||
ajax_form_title = _('Serialize Stock')
|
||||
#form_class = SerializeStockForm
|
||||
form_class = SerializeStockForm
|
||||
|
||||
def get_form(self):
|
||||
|
||||
@ -774,16 +774,8 @@ class StockItemSerialize(AjaxUpdateView):
|
||||
|
||||
item = self.get_object()
|
||||
|
||||
# Pre-calculate what the serial numbers should be!
|
||||
sn = item.part.getNextSerialNumber()
|
||||
|
||||
if item.quantity >= 2:
|
||||
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
||||
else:
|
||||
sn = str(sn)
|
||||
|
||||
initials['quantity'] = item.quantity
|
||||
initials['serial_numbers'] = sn
|
||||
initials['serial_numbers'] = item.part.getSerialNumberString(item.quantity)
|
||||
initials['destination'] = item.location.pk
|
||||
|
||||
return initials
|
||||
|
Loading…
x
Reference in New Issue
Block a user