Merge commit 'e5fa67ca9f021c14e9340619fe4a807f0c012ae2' into block-notes

This commit is contained in:
Oliver Walters
2026-06-25 05:11:04 +00:00
17 changed files with 114 additions and 40 deletions
@@ -1,16 +1,19 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 513
INVENTREE_API_VERSION = 514
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v513 -> 2026-06-25 : https://github.com/inventree/InvenTree/pull/11971
v514 -> 2026-06-25 : https://github.com/inventree/InvenTree/pull/11971
- Removes direct "notes" field from any models which previously supported markdown notes
- Adds a generic "Note" model which can be attached to any model type via a generic foreign key relationship
- Allow multiple notes to be attached to a single object, and for notes to be created / edited / deleted via the API
v513 -> 2026-06-25 : https://github.com/inventree/InvenTree/pull/12250
- Adds "active" field to the ProjectCode model and API endpoints
v512 -> 2026-06-20 : https://github.com/inventree/InvenTree/pull/12022
- Adds optional "merge" field to each item in the Stock Transfer API endpoint
- When merge is enabled, transferred stock is combined into compatible existing stock at the destination
+2 -1
View File
@@ -124,7 +124,8 @@ class BarcodeScanResultAdmin(admin.ModelAdmin):
class ProjectCodeAdmin(admin.ModelAdmin):
"""Admin settings for ProjectCode."""
list_display = ('code', 'description')
list_display = ('code', 'description', 'active')
list_filter = ('active',)
search_fields = ('code', 'description')
+1 -1
View File
@@ -512,7 +512,7 @@ class ProjectCodeList(DataExportViewMixin, ListCreateAPI):
filter_backends = SEARCH_ORDER_FILTER
ordering_fields = ['code']
filterset_fields = ['active']
search_fields = ['code', 'description']
@@ -0,0 +1,22 @@
# Generated by Django 5.2.15 on 2026-06-25 03:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("common", "0044_notificationmessage_charfield_pk"),
]
operations = [
migrations.AddField(
model_name="projectcode",
name="active",
field=models.BooleanField(
default=True,
help_text="Is this project code active?",
verbose_name="Active",
),
),
]
+6
View File
@@ -183,6 +183,12 @@ class ProjectCode(InvenTree.models.InvenTreeMetadataModel):
help_text=_('Project description'),
)
active = models.BooleanField(
default=True,
verbose_name=_('Active'),
help_text=_('Is this project code active?'),
)
responsible = models.ForeignKey(
users.models.Owner,
on_delete=models.SET_NULL,
+8 -1
View File
@@ -417,7 +417,14 @@ class ProjectCodeSerializer(DataImportExportSerializerMixin, InvenTreeModelSeria
"""Meta options for ProjectCodeSerializer."""
model = common_models.ProjectCode
fields = ['pk', 'code', 'description', 'responsible', 'responsible_detail']
fields = [
'pk',
'code',
'description',
'active',
'responsible',
'responsible_detail',
]
responsible_detail = OwnerSerializer(
source='responsible', read_only=True, allow_null=True
+16
View File
@@ -1813,6 +1813,22 @@ class ProjectCodesTest(InvenTreeAPITestCase):
str(response.data['code']),
)
def test_filter_active(self):
"""Test that the 'active' field can be filtered via the API."""
# Mark one code as inactive
code = ProjectCode.objects.first()
code.active = False
code.save()
active_count = ProjectCode.objects.filter(active=True).count()
inactive_count = ProjectCode.objects.filter(active=False).count()
response = self.get(self.url, data={'active': True}, expected_code=200)
self.assertEqual(len(response.data), active_count)
response = self.get(self.url, data={'active': False}, expected_code=200)
self.assertEqual(len(response.data), inactive_count)
def test_write_access(self):
"""Test that non-staff users have read-only access."""
# By default user has staff access, can create a new project code