mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-30 18:50:53 +00:00
Merge branch 'feature-non-int-serial' of git://github.com/bcc/InvenTree into bcc-feature-non-int-serial
This commit is contained in:
18
InvenTree/stock/migrations/0050_auto_20200821_1403.py
Normal file
18
InvenTree/stock/migrations/0050_auto_20200821_1403.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.7 on 2020-08-21 14:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0049_auto_20200820_0454'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stockitem',
|
||||
name='serial',
|
||||
field=models.CharField(blank=True, help_text='Serial number for this item', max_length=100, null=True, verbose_name='Serial Number'),
|
||||
),
|
||||
]
|
@ -355,9 +355,9 @@ class StockItem(MPTTModel):
|
||||
verbose_name=_("Customer"),
|
||||
)
|
||||
|
||||
serial = models.PositiveIntegerField(
|
||||
serial = models.CharField(
|
||||
verbose_name=_('Serial Number'),
|
||||
blank=True, null=True,
|
||||
max_length=100, blank=True, null=True,
|
||||
help_text=_('Serial number for this item')
|
||||
)
|
||||
|
||||
@ -687,9 +687,6 @@ class StockItem(MPTTModel):
|
||||
if not type(serials) in [list, tuple]:
|
||||
raise ValidationError({"serial_numbers": _("Serial numbers must be a list of integers")})
|
||||
|
||||
if any([type(i) is not int for i in serials]):
|
||||
raise ValidationError({"serial_numbers": _("Serial numbers must be a list of integers")})
|
||||
|
||||
if not quantity == len(serials):
|
||||
raise ValidationError({"quantity": _("Quantity does not match serial numbers")})
|
||||
|
||||
|
@ -113,7 +113,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
||||
|
||||
allocated = serializers.FloatField(source='allocation_count', required=False)
|
||||
|
||||
serial = serializers.IntegerField(required=False)
|
||||
serial = serializers.CharField(required=False)
|
||||
|
||||
required_tests = serializers.IntegerField(source='required_test_count', read_only=True, required=False)
|
||||
|
||||
|
@ -295,10 +295,7 @@ class StockTest(TestCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
item.serializeStock(-1, [], self.user)
|
||||
|
||||
# Try invalid serial numbers
|
||||
with self.assertRaises(ValidationError):
|
||||
item.serializeStock(3, [1, 2, 'k'], self.user)
|
||||
|
||||
# Not enough serial numbers for all stock items.
|
||||
with self.assertRaises(ValidationError):
|
||||
item.serializeStock(3, "hello", self.user)
|
||||
|
||||
@ -394,8 +391,16 @@ class VariantTest(StockTest):
|
||||
with self.assertRaises(ValidationError):
|
||||
item.save()
|
||||
|
||||
# This should pass
|
||||
item.serial = n + 1
|
||||
# Verify items with a non-numeric serial don't offer a next serial.
|
||||
item.serial = "string"
|
||||
item.save()
|
||||
self.assertEqual(variant.getNextSerialNumber(), None)
|
||||
|
||||
# And the same for the range when serializing.
|
||||
self.assertEqual(variant.getSerialNumberString(5), None)
|
||||
|
||||
# This should pass, although not strictly an int field now.
|
||||
item.serial = int(n) + 1
|
||||
item.save()
|
||||
|
||||
# Attempt to create the same serial number but for a variant (should fail!)
|
||||
|
Reference in New Issue
Block a user