mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add helper fnc to get latest SN as int
This commit is contained in:
parent
771f3d6b7b
commit
1d0aa900e8
@ -583,6 +583,26 @@ class Part(MPTTModel):
|
||||
# No serial numbers found
|
||||
return None
|
||||
|
||||
def getLatestSerialNumberInt(self):
|
||||
"""
|
||||
Return the "latest" serial number for this Part as a integer.
|
||||
If it is not an integer the result is 0
|
||||
"""
|
||||
|
||||
latest = self.getLatestSerialNumber()
|
||||
|
||||
# No serial number = > 0
|
||||
if latest is None:
|
||||
latest = 0
|
||||
|
||||
# Attempt to turn into an integer and return
|
||||
try:
|
||||
latest = int(latest)
|
||||
return latest
|
||||
except:
|
||||
# not an integer so 0
|
||||
return 0
|
||||
|
||||
def getSerialNumberString(self, quantity=1):
|
||||
"""
|
||||
Return a formatted string representing the next available serial numbers,
|
||||
|
Loading…
Reference in New Issue
Block a user