diff --git a/src/backend/InvenTree/common/migrations/0044_note.py b/src/backend/InvenTree/common/migrations/0044_note.py index 7213ac9252..28a9c45c82 100644 --- a/src/backend/InvenTree/common/migrations/0044_note.py +++ b/src/backend/InvenTree/common/migrations/0044_note.py @@ -47,11 +47,15 @@ class Migration(migrations.Migration): verbose_name="Updated", ), ), - ("model_id", models.PositiveIntegerField()), + ("model_id", models.PositiveIntegerField( + blank=True, + null=True, + help_text="Target model instance ID for this note", + )), ( "title", models.CharField( - help_text="Note title", max_length=100, verbose_name="Title" + help_text="Note title", max_length=100, verbose_name="Title", ), ), ( @@ -74,6 +78,17 @@ class Migration(migrations.Migration): models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, to="contenttypes.contenttype", + help_text="Target model type for this note", + blank=True, + null=True, + ), + ), + ( + "template", + models.BooleanField( + default=False, + help_text="Is this note a template (not linked to a specific model instance)?", + verbose_name="Template", ), ), ( @@ -125,7 +140,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="note", constraint=models.UniqueConstraint( - condition=models.Q(("primary", True)), + condition=models.Q(("primary", True), ("template", False)), fields=("model_type", "model_id"), name="unique_primary_note_per_model", ), diff --git a/src/backend/InvenTree/common/models.py b/src/backend/InvenTree/common/models.py index 0472f91e42..e4c83b7f90 100644 --- a/src/backend/InvenTree/common/models.py +++ b/src/backend/InvenTree/common/models.py @@ -3178,15 +3178,11 @@ class Note( on_delete=models.CASCADE, null=True, blank=True, - help_text=_( - 'Target model type for this note (null = applies to all model types)' - ), + help_text=_('Target model type for this note'), ) model_id = models.PositiveIntegerField( - null=True, - blank=True, - help_text=_('Target model instance ID for this note (null for templates)'), + null=True, blank=True, help_text=_('Target model instance ID for this note') ) content_object = GenericForeignKey('model_type', 'model_id')