From caa7b84c3e7705afd98ac9741d8212a7eb5969a6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 15 May 2023 10:57:12 +1000 Subject: [PATCH] Allow tag fields to be empty (#4816) Without this change, editing items (e.g. via the admin interface) fails if the tag field is not empty --- .../migrations/0058_auto_20230515_0004.py | 25 +++++++++++++++++++ InvenTree/company/models.py | 5 ++-- .../part/migrations/0107_alter_part_tags.py | 20 +++++++++++++++ InvenTree/part/models.py | 3 ++- .../migrations/0100_auto_20230515_0004.py | 25 +++++++++++++++++++ InvenTree/stock/models.py | 4 +-- 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 InvenTree/company/migrations/0058_auto_20230515_0004.py create mode 100644 InvenTree/part/migrations/0107_alter_part_tags.py create mode 100644 InvenTree/stock/migrations/0100_auto_20230515_0004.py diff --git a/InvenTree/company/migrations/0058_auto_20230515_0004.py b/InvenTree/company/migrations/0058_auto_20230515_0004.py new file mode 100644 index 0000000000..8190df46fb --- /dev/null +++ b/InvenTree/company/migrations/0058_auto_20230515_0004.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.19 on 2023-05-15 00:04 + +from django.db import migrations +import taggit.managers + + +class Migration(migrations.Migration): + + dependencies = [ + ('taggit', '0005_auto_20220424_2025'), + ('company', '0057_auto_20230427_2033'), + ] + + operations = [ + migrations.AlterField( + model_name='manufacturerpart', + name='tags', + field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), + ), + migrations.AlterField( + model_name='supplierpart', + name='tags', + field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), + ), + ] diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index 3170657f58..7e03e7187a 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -311,7 +311,7 @@ class ManufacturerPart(MetadataMixin, models.Model): help_text=_('Manufacturer part description') ) - tags = TaggableManager() + tags = TaggableManager(blank=True) @classmethod def create(cls, part, manufacturer, mpn, description, link=None): @@ -448,7 +448,8 @@ class SupplierPart(MetadataMixin, InvenTreeBarcodeMixin, common.models.MetaMixin db_table = 'part_supplierpart' objects = SupplierPartManager() - tags = TaggableManager() + + tags = TaggableManager(blank=True) @staticmethod def get_api_url(): diff --git a/InvenTree/part/migrations/0107_alter_part_tags.py b/InvenTree/part/migrations/0107_alter_part_tags.py new file mode 100644 index 0000000000..15ce10f530 --- /dev/null +++ b/InvenTree/part/migrations/0107_alter_part_tags.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.19 on 2023-05-15 00:04 + +from django.db import migrations +import taggit.managers + + +class Migration(migrations.Migration): + + dependencies = [ + ('taggit', '0005_auto_20220424_2025'), + ('part', '0106_part_tags'), + ] + + operations = [ + migrations.AlterField( + model_name='part', + name='tags', + field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 87f1c6d33a..a9fd88fbee 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -380,7 +380,8 @@ class Part(InvenTreeBarcodeMixin, InvenTreeNotesMixin, MetadataMixin, MPTTModel) """ objects = PartManager() - tags = TaggableManager() + + tags = TaggableManager(blank=True) class Meta: """Metaclass defines extra model properties""" diff --git a/InvenTree/stock/migrations/0100_auto_20230515_0004.py b/InvenTree/stock/migrations/0100_auto_20230515_0004.py new file mode 100644 index 0000000000..ed5b923979 --- /dev/null +++ b/InvenTree/stock/migrations/0100_auto_20230515_0004.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.19 on 2023-05-15 00:04 + +from django.db import migrations +import taggit.managers + + +class Migration(migrations.Migration): + + dependencies = [ + ('taggit', '0005_auto_20220424_2025'), + ('stock', '0099_alter_stockitem_status'), + ] + + operations = [ + migrations.AlterField( + model_name='stockitem', + name='tags', + field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), + ), + migrations.AlterField( + model_name='stocklocation', + name='tags', + field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index ca083cee3b..498e59eee6 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -54,7 +54,7 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree): verbose_name = _('Stock Location') verbose_name_plural = _('Stock Locations') - tags = TaggableManager() + tags = TaggableManager(blank=True) def delete_recursive(self, *args, **kwargs): """This function handles the recursive deletion of sub-locations depending on kwargs contents""" @@ -324,7 +324,7 @@ class StockItem(InvenTreeBarcodeMixin, InvenTreeNotesMixin, MetadataMixin, commo } } - tags = TaggableManager() + tags = TaggableManager(blank=True) # A Query filter which will be re-used in multiple places to determine if a StockItem is actually "in stock" IN_STOCK_FILTER = Q(