mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-11 07:24:15 +00:00
Update validation "rules" for BuildItem
- A BuildItem which points to a trackable part must also point to a build output - A BuildItem which points to a non-trackable part cannot point to a build output
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import transaction
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from build.models import Build, BuildItem
|
||||
@ -144,13 +143,15 @@ class BuildTest(TestCase):
|
||||
quantity=q21
|
||||
)
|
||||
|
||||
with transaction.atomic():
|
||||
with self.assertRaises(IntegrityError):
|
||||
BuildItem.objects.create(
|
||||
build=self.build,
|
||||
stock_item=self.stock_2_1,
|
||||
quantity=99
|
||||
)
|
||||
# Attempt to create another identical BuildItem
|
||||
b = BuildItem(
|
||||
build=self.build,
|
||||
stock_item=self.stock_2_1,
|
||||
quantity=q21
|
||||
)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
b.clean()
|
||||
|
||||
self.assertEqual(BuildItem.objects.count(), 3)
|
||||
|
||||
|
Reference in New Issue
Block a user