2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-10 23:14:13 +00:00

Build part change fix (#5808)

* Add DiffMixin class

- Allows us to compute "diffs" against items stored in the database, when they are being updated

* Prevent build order part from being changed after creation

* Remove "part" field from buildorder edit form

* Add unit test
This commit is contained in:
Oliver
2023-10-29 23:13:38 +11:00
committed by GitHub
parent 4cd4a84bac
commit a1f9260da6
4 changed files with 86 additions and 1 deletions

View File

@ -471,6 +471,28 @@ class BuildTest(BuildTestBase):
# Check that the "consumed_by" item count has increased
self.assertEqual(StockItem.objects.filter(consumed_by=self.build).count(), n + 8)
def test_change_part(self):
"""Try to change target part after creating a build"""
bo = Build.objects.create(
reference='BO-9999',
title='Some new build',
part=self.assembly,
quantity=5,
issued_by=get_user_model().objects.get(pk=1),
)
assembly_2 = Part.objects.create(
name="Another assembly",
description="A different assembly",
assembly=True,
)
# Should not be able to change the part after the Build is saved
with self.assertRaises(ValidationError):
bo.part = assembly_2
bo.save()
def test_cancel(self):
"""Test cancellation of the build"""
# TODO