Browse Source

修复序列号生成bug

lang 4 năm trước cách đây
mục cha
commit
3ff2ac27be

+ 4 - 1
Controller/SerialNumberController.py

@@ -69,7 +69,10 @@ class SerialNumberView(View):
         algorithm = AlgorithmBaseOn35()
         algorithm = AlgorithmBaseOn35()
 
 
         for i in range(quantity):
         for i in range(quantity):
-            sum = SerialNumberModel.objects.last().id + 1
+            try:
+                sum = SerialNumberModel.objects.last().id
+            except:
+                sum = 0
             serial_number = algorithm.getLetter(sum)
             serial_number = algorithm.getLetter(sum)
             tmp_len = 6 - len(serial_number)
             tmp_len = 6 - len(serial_number)
             # 前面补0
             # 前面补0