2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-01-10 05:08:09 +00:00

Bug fix for stock entry calculation (#11103)

- Additional unit testing
This commit is contained in:
Oliver
2026-01-09 11:01:03 +11:00
committed by GitHub
parent ff9f465b8b
commit be711464ff
2 changed files with 11 additions and 1 deletions

View File

@@ -1819,7 +1819,7 @@ class Part(
if include_external is False:
# Exclude stock entries which are not 'internal'
query = query.filter(external=False)
query = query.filter(location__external=False)
if location:
locations = location.get_descendants(include_self=True)

View File

@@ -867,6 +867,16 @@ class VariantTest(StockTestBase):
self.assertEqual(green.stock_entries(include_variants=False).count(), 0)
self.assertEqual(green.stock_entries().count(), 3)
# Test with an "external" location
entry = green.stock_entries().first()
entry.location = StockLocation.objects.create(
name='External Location', description='An external location', external=True
)
entry.save()
self.assertEqual(green.stock_entries(include_external=True).count(), 3)
self.assertEqual(green.stock_entries(include_external=False).count(), 2)
def test_serial_numbers(self):
"""Test serial number functionality for variant / template parts."""
InvenTreeSetting.set_setting('SERIAL_NUMBER_GLOBALLY_UNIQUE', False, self.user)