mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge branch 'inventree:master' into matmair/issue2694
This commit is contained in:
commit
56142b9303
@ -350,7 +350,7 @@ class StockItem(MPTTModel):
|
|||||||
@property
|
@property
|
||||||
def serialized(self):
|
def serialized(self):
|
||||||
""" Return True if this StockItem is serialized """
|
""" Return True if this StockItem is serialized """
|
||||||
return self.serial is not None and self.quantity == 1
|
return self.serial is not None and len(str(self.serial).strip()) > 0 and self.quantity == 1
|
||||||
|
|
||||||
def validate_unique(self, exclude=None):
|
def validate_unique(self, exclude=None):
|
||||||
"""
|
"""
|
||||||
|
@ -346,6 +346,40 @@ class StockTest(TestCase):
|
|||||||
with self.assertRaises(StockItem.DoesNotExist):
|
with self.assertRaises(StockItem.DoesNotExist):
|
||||||
w2 = StockItem.objects.get(pk=101)
|
w2 = StockItem.objects.get(pk=101)
|
||||||
|
|
||||||
|
def test_serials(self):
|
||||||
|
"""
|
||||||
|
Tests for stock serialization
|
||||||
|
"""
|
||||||
|
|
||||||
|
p = Part.objects.create(
|
||||||
|
name='trackable part',
|
||||||
|
description='trackable part',
|
||||||
|
trackable=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
item = StockItem.objects.create(
|
||||||
|
part=p,
|
||||||
|
quantity=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertFalse(item.serialized)
|
||||||
|
|
||||||
|
item.serial = None
|
||||||
|
item.save()
|
||||||
|
self.assertFalse(item.serialized)
|
||||||
|
|
||||||
|
item.serial = ' '
|
||||||
|
item.save()
|
||||||
|
self.assertFalse(item.serialized)
|
||||||
|
|
||||||
|
item.serial = ''
|
||||||
|
item.save()
|
||||||
|
self.assertFalse(item.serialized)
|
||||||
|
|
||||||
|
item.serial = '1'
|
||||||
|
item.save()
|
||||||
|
self.assertTrue(item.serialized)
|
||||||
|
|
||||||
def test_serialize_stock_invalid(self):
|
def test_serialize_stock_invalid(self):
|
||||||
"""
|
"""
|
||||||
Test manual serialization of parts.
|
Test manual serialization of parts.
|
||||||
|
Loading…
Reference in New Issue
Block a user