mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-11 07:24:15 +00:00
Refactoring Build model functions
- Determining if a build order is correctly allocated has become more complex - Complex BOM behaviours (e.g. variants, templates, and substitutes) have made it more difficult! - Recently, a reference to the defining BomItem object was added to the BuildItem model - Now, a simpler way is to check allocation against the parent BomItem - It is much better, but means that a lot of refactoring and testing will be required!
This commit is contained in:
@ -147,15 +147,15 @@ class BuildTest(TestCase):
|
||||
|
||||
# None of the build outputs have been completed
|
||||
for output in self.build.get_build_outputs().all():
|
||||
self.assertFalse(self.build.isFullyAllocated(output))
|
||||
self.assertFalse(self.build.is_fully_allocated(output))
|
||||
|
||||
self.assertFalse(self.build.isPartFullyAllocated(self.sub_part_1, self.output_1))
|
||||
self.assertFalse(self.build.isPartFullyAllocated(self.sub_part_2, self.output_2))
|
||||
self.assertFalse(self.build.is_bom_item_allocated(self.sub_part_1, self.output_1))
|
||||
self.assertFalse(self.build.is_bom_item_allocated(self.sub_part_2, self.output_2))
|
||||
|
||||
self.assertEqual(self.build.unallocatedQuantity(self.sub_part_1, self.output_1), 15)
|
||||
self.assertEqual(self.build.unallocatedQuantity(self.sub_part_1, self.output_2), 35)
|
||||
self.assertEqual(self.build.unallocatedQuantity(self.sub_part_2, self.output_1), 9)
|
||||
self.assertEqual(self.build.unallocatedQuantity(self.sub_part_2, self.output_2), 21)
|
||||
self.assertEqual(self.build.unallocated_quantity(self.sub_part_1, self.output_1), 15)
|
||||
self.assertEqual(self.build.unallocated_quantity(self.sub_part_1, self.output_2), 35)
|
||||
self.assertEqual(self.build.unallocated_quantity(self.sub_part_2, self.output_1), 9)
|
||||
self.assertEqual(self.build.unallocated_quantity(self.sub_part_2, self.output_2), 21)
|
||||
|
||||
self.assertFalse(self.build.is_complete)
|
||||
|
||||
@ -226,7 +226,7 @@ class BuildTest(TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertTrue(self.build.isFullyAllocated(self.output_1))
|
||||
self.assertTrue(self.build.is_fully_allocated(self.output_1))
|
||||
|
||||
# Partially allocate tracked stock against build output 2
|
||||
self.allocate_stock(
|
||||
@ -236,7 +236,7 @@ class BuildTest(TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertFalse(self.build.isFullyAllocated(self.output_2))
|
||||
self.assertFalse(self.build.is_fully_allocated(self.output_2))
|
||||
|
||||
# Partially allocate untracked stock against build
|
||||
self.allocate_stock(
|
||||
@ -247,9 +247,9 @@ class BuildTest(TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertFalse(self.build.isFullyAllocated(None, verbose=True))
|
||||
self.assertFalse(self.build.is_fully_allocated(None, verbose=True))
|
||||
|
||||
unallocated = self.build.unallocatedParts(None)
|
||||
unallocated = self.build.unallocated_bom_items(None)
|
||||
|
||||
self.assertEqual(len(unallocated), 2)
|
||||
|
||||
@ -260,19 +260,19 @@ class BuildTest(TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertFalse(self.build.isFullyAllocated(None, verbose=True))
|
||||
self.assertFalse(self.build.is_fully_allocated(None, verbose=True))
|
||||
|
||||
unallocated = self.build.unallocatedParts(None)
|
||||
unallocated = self.build.unallocated_bom_items(None)
|
||||
|
||||
self.assertEqual(len(unallocated), 1)
|
||||
|
||||
self.build.unallocateStock()
|
||||
|
||||
unallocated = self.build.unallocatedParts(None)
|
||||
unallocated = self.build.unallocated_bom_items(None)
|
||||
|
||||
self.assertEqual(len(unallocated), 2)
|
||||
|
||||
self.assertFalse(self.build.areUntrackedPartsFullyAllocated())
|
||||
self.assertFalse(self.build.are_untracked_parts_allocated())
|
||||
|
||||
# Now we "fully" allocate the untracked untracked items
|
||||
self.allocate_stock(
|
||||
@ -283,7 +283,7 @@ class BuildTest(TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertTrue(self.build.areUntrackedPartsFullyAllocated())
|
||||
self.assertTrue(self.build.are_untracked_parts_allocated())
|
||||
|
||||
def test_cancel(self):
|
||||
"""
|
||||
@ -331,9 +331,9 @@ class BuildTest(TestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertTrue(self.build.isFullyAllocated(None, verbose=True))
|
||||
self.assertTrue(self.build.isFullyAllocated(self.output_1))
|
||||
self.assertTrue(self.build.isFullyAllocated(self.output_2))
|
||||
self.assertTrue(self.build.is_fully_allocated(None, verbose=True))
|
||||
self.assertTrue(self.build.is_fully_allocated(self.output_1))
|
||||
self.assertTrue(self.build.is_fully_allocated(self.output_2))
|
||||
|
||||
self.build.complete_build_output(self.output_1, None)
|
||||
|
||||
|
Reference in New Issue
Block a user