From 3e2f6f8935bc4aaeb290c1d3b456c20d8dc3bb0e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 21 Jul 2026 06:44:02 +0000 Subject: [PATCH] Fix for note save --- src/backend/InvenTree/common/models.py | 4 ++- src/backend/InvenTree/part/test_api.py | 34 -------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/backend/InvenTree/common/models.py b/src/backend/InvenTree/common/models.py index f2d602910f..025661eeb6 100644 --- a/src/backend/InvenTree/common/models.py +++ b/src/backend/InvenTree/common/models.py @@ -3118,8 +3118,10 @@ class Note( super().save(*args, **kwargs) # Mark other notes as non-primary + # Note: re-exclude on self.pk here, as it was None (and thus a no-op + # exclusion) when the 'siblings' queryset was built above for a new note if self.primary: - siblings.update(primary=False) + siblings.exclude(pk=self.pk).update(primary=False) else: # Templates skip primary-flag logic entirely self.primary = False diff --git a/src/backend/InvenTree/part/test_api.py b/src/backend/InvenTree/part/test_api.py index b7763b969e..44607d1217 100644 --- a/src/backend/InvenTree/part/test_api.py +++ b/src/backend/InvenTree/part/test_api.py @@ -1620,40 +1620,6 @@ class PartCreationTests(PartAPITestBase): self.assertFalse(response.data['active']) self.assertFalse(response.data['purchaseable']) - def test_notes_on_create(self): - """Test that notes can be set when creating a Part.""" - list_url = reverse('api-part-list') - - notes = """ - ### Created from importer - - Notes should persist during part creation. - """ - expected_notes = notes.strip() - - response = self.post( - list_url, - { - 'name': 'part with notes', - 'description': 'Part notes are created in the same request', - 'category': 1, - 'notes': notes, - }, - expected_code=201, - ) - - self.assertEqual(response.data['notes'], expected_notes) - - part = Part.objects.get(pk=response.data['pk']) - self.assertEqual(part.notes, expected_notes) - - detail_url = reverse('api-part-detail', kwargs={'pk': part.pk}) - response = self.get(detail_url, expected_code=200) - self.assertEqual(response.data['notes'], expected_notes) - - response = self.get(list_url, {'limit': 1}, expected_code=200) - self.assertNotIn('notes', response.data['results'][0]) - def test_initial_stock(self): """Tests for initial stock quantity creation."""