mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor function naming
This commit is contained in:
parent
4cb97b1340
commit
3d0bea15ae
@ -282,7 +282,7 @@ class BuildComplete(AjaxUpdateView):
|
|||||||
existing = []
|
existing = []
|
||||||
|
|
||||||
for serial in serials:
|
for serial in serials:
|
||||||
if not StockItem.check_serial_number(build.part, serial):
|
if build.part.checkIfSerialNumberExists(serial):
|
||||||
existing.append(serial)
|
existing.append(serial)
|
||||||
|
|
||||||
if len(existing) > 0:
|
if len(existing) > 0:
|
||||||
|
@ -266,7 +266,7 @@ class Part(MPTTModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{n} - {d}".format(n=self.full_name, d=self.description)
|
return "{n} - {d}".format(n=self.full_name, d=self.description)
|
||||||
|
|
||||||
def check_if_serial_number_exists(self, sn):
|
def checkIfSerialNumberExists(self, sn):
|
||||||
"""
|
"""
|
||||||
Check if a serial number exists for this Part.
|
Check if a serial number exists for this Part.
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ class Part(MPTTModel):
|
|||||||
|
|
||||||
return stock.exists()
|
return stock.exists()
|
||||||
|
|
||||||
def get_highest_serial_number(self):
|
def getHighestSerialNumber(self):
|
||||||
"""
|
"""
|
||||||
Return the highest serial number for this Part.
|
Return the highest serial number for this Part.
|
||||||
|
|
||||||
@ -296,12 +296,12 @@ class Part(MPTTModel):
|
|||||||
# No serial numbers found
|
# No serial numbers found
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_next_serial_number(self):
|
def getNextSerialNumber(self):
|
||||||
"""
|
"""
|
||||||
Return the next-available serial number for this Part.
|
Return the next-available serial number for this Part.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
n = self.get_highest_serial_number()
|
n = self.getHighestSerialNumber()
|
||||||
|
|
||||||
if n is None:
|
if n is None:
|
||||||
return 1
|
return 1
|
||||||
|
@ -113,7 +113,7 @@ class SerializeStockForm(HelperForm):
|
|||||||
if item:
|
if item:
|
||||||
|
|
||||||
# Pre-calculate what the serial numbers should be!
|
# Pre-calculate what the serial numbers should be!
|
||||||
sn = item.part.get_next_serial_number()
|
sn = item.part.getNextSerialNumber()
|
||||||
|
|
||||||
if item.quantity >= 2:
|
if item.quantity >= 2:
|
||||||
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
||||||
|
@ -606,7 +606,7 @@ class StockItem(MPTTModel):
|
|||||||
existing = []
|
existing = []
|
||||||
|
|
||||||
for serial in serials:
|
for serial in serials:
|
||||||
if self.part.check_if_serial_number_exists(serial):
|
if self.part.checkIfSerialNumberExists(serial):
|
||||||
existing.append(serial)
|
existing.append(serial)
|
||||||
|
|
||||||
if len(existing) > 0:
|
if len(existing) > 0:
|
||||||
|
@ -361,26 +361,26 @@ class VariantTest(StockTest):
|
|||||||
chair = Part.objects.get(pk=10000)
|
chair = Part.objects.get(pk=10000)
|
||||||
|
|
||||||
# Operations on the top-level object
|
# Operations on the top-level object
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(1))
|
self.assertTrue(chair.checkIfSerialNumberExists(1))
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(2))
|
self.assertTrue(chair.checkIfSerialNumberExists(2))
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(3))
|
self.assertTrue(chair.checkIfSerialNumberExists(3))
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(4))
|
self.assertTrue(chair.checkIfSerialNumberExists(4))
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(5))
|
self.assertTrue(chair.checkIfSerialNumberExists(5))
|
||||||
|
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(20))
|
self.assertTrue(chair.checkIfSerialNumberExists(20))
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(21))
|
self.assertTrue(chair.checkIfSerialNumberExists(21))
|
||||||
self.assertTrue(chair.check_if_serial_number_exists(22))
|
self.assertTrue(chair.checkIfSerialNumberExists(22))
|
||||||
|
|
||||||
self.assertFalse(chair.check_if_serial_number_exists(30))
|
self.assertFalse(chair.checkIfSerialNumberExists(30))
|
||||||
|
|
||||||
self.assertEqual(chair.get_next_serial_number(), 23)
|
self.assertEqual(chair.getNextSerialNumber(), 23)
|
||||||
|
|
||||||
# Same operations on a sub-item
|
# Same operations on a sub-item
|
||||||
variant = Part.objects.get(pk=10003)
|
variant = Part.objects.get(pk=10003)
|
||||||
self.assertEqual(variant.get_next_serial_number(), 23)
|
self.assertEqual(variant.getNextSerialNumber(), 23)
|
||||||
|
|
||||||
# Create a new serial number
|
# Create a new serial number
|
||||||
n = variant.get_highest_serial_number()
|
n = variant.getHighestSerialNumber()
|
||||||
|
|
||||||
item = StockItem(
|
item = StockItem(
|
||||||
part=variant,
|
part=variant,
|
||||||
|
@ -775,7 +775,7 @@ class StockItemSerialize(AjaxUpdateView):
|
|||||||
item = self.get_object()
|
item = self.get_object()
|
||||||
|
|
||||||
# Pre-calculate what the serial numbers should be!
|
# Pre-calculate what the serial numbers should be!
|
||||||
sn = item.part.get_next_serial_number()
|
sn = item.part.getNextSerialNumber()
|
||||||
|
|
||||||
if item.quantity >= 2:
|
if item.quantity >= 2:
|
||||||
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
||||||
|
Loading…
Reference in New Issue
Block a user