diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 6f651a7628..96eb602f2b 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -282,7 +282,7 @@ class BuildComplete(AjaxUpdateView): existing = [] for serial in serials: - if not StockItem.check_serial_number(build.part, serial): + if build.part.checkIfSerialNumberExists(serial): existing.append(serial) if len(existing) > 0: diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 0fdf764961..31771dc291 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -266,7 +266,7 @@ class Part(MPTTModel): def __str__(self): 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. @@ -279,7 +279,7 @@ class Part(MPTTModel): return stock.exists() - def get_highest_serial_number(self): + def getHighestSerialNumber(self): """ Return the highest serial number for this Part. @@ -296,12 +296,12 @@ class Part(MPTTModel): # No serial numbers found return None - def get_next_serial_number(self): + def getNextSerialNumber(self): """ Return the next-available serial number for this Part. """ - n = self.get_highest_serial_number() + n = self.getHighestSerialNumber() if n is None: return 1 diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index 4eaff44b74..520ac72835 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -113,7 +113,7 @@ class SerializeStockForm(HelperForm): if item: # Pre-calculate what the serial numbers should be! - sn = item.part.get_next_serial_number() + sn = item.part.getNextSerialNumber() if item.quantity >= 2: sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1)) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index bf9c763ae7..e0f38ba871 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -606,7 +606,7 @@ class StockItem(MPTTModel): existing = [] for serial in serials: - if self.part.check_if_serial_number_exists(serial): + if self.part.checkIfSerialNumberExists(serial): existing.append(serial) if len(existing) > 0: diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index 307879629a..ab038c3c62 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -361,26 +361,26 @@ class VariantTest(StockTest): chair = Part.objects.get(pk=10000) # Operations on the top-level object - self.assertTrue(chair.check_if_serial_number_exists(1)) - self.assertTrue(chair.check_if_serial_number_exists(2)) - self.assertTrue(chair.check_if_serial_number_exists(3)) - self.assertTrue(chair.check_if_serial_number_exists(4)) - self.assertTrue(chair.check_if_serial_number_exists(5)) + self.assertTrue(chair.checkIfSerialNumberExists(1)) + self.assertTrue(chair.checkIfSerialNumberExists(2)) + self.assertTrue(chair.checkIfSerialNumberExists(3)) + self.assertTrue(chair.checkIfSerialNumberExists(4)) + self.assertTrue(chair.checkIfSerialNumberExists(5)) - self.assertTrue(chair.check_if_serial_number_exists(20)) - self.assertTrue(chair.check_if_serial_number_exists(21)) - self.assertTrue(chair.check_if_serial_number_exists(22)) + self.assertTrue(chair.checkIfSerialNumberExists(20)) + self.assertTrue(chair.checkIfSerialNumberExists(21)) + 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 variant = Part.objects.get(pk=10003) - self.assertEqual(variant.get_next_serial_number(), 23) + self.assertEqual(variant.getNextSerialNumber(), 23) # Create a new serial number - n = variant.get_highest_serial_number() + n = variant.getHighestSerialNumber() item = StockItem( part=variant, diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index a7195a5300..ee5367e346 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -775,7 +775,7 @@ class StockItemSerialize(AjaxUpdateView): item = self.get_object() # Pre-calculate what the serial numbers should be! - sn = item.part.get_next_serial_number() + sn = item.part.getNextSerialNumber() if item.quantity >= 2: sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))