From 68b53acbf1253e6c7bdf2b6fc477b12ab0ba9fc6 Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Wed, 12 May 2021 08:07:03 +1000 Subject: [PATCH] remove old fields from the StockItemTracking model --- InvenTree/stock/api.py | 2 +- InvenTree/stock/forms.py | 7 +++-- .../migrations/0063_auto_20210511_2343.py | 29 +++++++++++++++++++ InvenTree/stock/models.py | 22 -------------- 4 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 InvenTree/stock/migrations/0063_auto_20210511_2343.py diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index b0b6ae1c24..809c354720 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -389,7 +389,7 @@ class StockList(generics.ListCreateAPIView): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) - item = serializer.save(user=user, commit=False) + item = serializer.save(user=user) # A location was *not* specified - try to infer it if 'location' not in request.data: diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index 6d7f8d40ed..92089623f9 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -437,14 +437,15 @@ class EditStockItemForm(HelperForm): class TrackingEntryForm(HelperForm): - """ Form for creating / editing a StockItemTracking object. + """ + Form for creating / editing a StockItemTracking object. + + Note: 2021-05-11 - This form is not currently used - should delete? """ class Meta: model = StockItemTracking fields = [ - 'title', 'notes', - 'link', ] diff --git a/InvenTree/stock/migrations/0063_auto_20210511_2343.py b/InvenTree/stock/migrations/0063_auto_20210511_2343.py new file mode 100644 index 0000000000..dc8a391cde --- /dev/null +++ b/InvenTree/stock/migrations/0063_auto_20210511_2343.py @@ -0,0 +1,29 @@ +# Generated by Django 3.2 on 2021-05-11 13:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0062_auto_20210511_2151'), + ] + + operations = [ + migrations.RemoveField( + model_name='stockitemtracking', + name='link', + ), + migrations.RemoveField( + model_name='stockitemtracking', + name='quantity', + ), + migrations.RemoveField( + model_name='stockitemtracking', + name='system', + ), + migrations.RemoveField( + model_name='stockitemtracking', + name='title', + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index bae1bc5135..3c702fdbe8 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -1626,13 +1626,10 @@ class StockItemTracking(models.Model): Attributes: item: ForeignKey reference to a particular StockItem date: Date that this tracking info was created - title: Title of this tracking info (legacy, no longer used!) tracking_type: The type of tracking information notes: Associated notes (input by user) - link: Optional URL to external page user: The user associated with this tracking info deltas: The changes associated with this history item - quantity: The StockItem quantity at this point in time """ def get_absolute_url(self): @@ -1657,13 +1654,6 @@ class StockItemTracking(models.Model): date = models.DateTimeField(auto_now_add=True, editable=False) - title = models.CharField( - blank=True, null=True, - max_length=250, - verbose_name=_('Title'), - help_text=_('Tracking entry title') - ) - notes = models.CharField( blank=True, null=True, max_length=512, @@ -1671,22 +1661,10 @@ class StockItemTracking(models.Model): help_text=_('Entry notes') ) - link = InvenTreeURLField(blank=True, verbose_name=_('Link'), help_text=_('Link to external page for further information')) - user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True) - system = models.BooleanField(default=False) - deltas = models.JSONField(null=True, blank=True) - quantity = models.DecimalField( - max_digits=15, - decimal_places=5, - validators=[MinValueValidator(0)], - default=1, - verbose_name=_('Quantity') - ) - def rename_stock_item_test_result_attachment(instance, filename):