From 339126b27adeab175a9168986a411b7239d3d393 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 16 Nov 2019 19:41:36 +1100 Subject: [PATCH] Add new field "active" to StockItem model - True by default - Set to 'false' to mark a stockitem as 'deleted' --- .../stock/migrations/0016_stockitem_active.py | 18 ++++++++++++++++++ InvenTree/stock/models.py | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 InvenTree/stock/migrations/0016_stockitem_active.py diff --git a/InvenTree/stock/migrations/0016_stockitem_active.py b/InvenTree/stock/migrations/0016_stockitem_active.py new file mode 100644 index 0000000000..1fb317a307 --- /dev/null +++ b/InvenTree/stock/migrations/0016_stockitem_active.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.5 on 2019-11-16 08:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0015_auto_20190913_1407'), + ] + + operations = [ + migrations.AddField( + model_name='stockitem', + name='active', + field=models.BooleanField(default=True), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 1cf1a870b8..7edd161b69 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -121,6 +121,7 @@ class StockItem(models.Model): build: Link to a Build (if this stock item was created from a build) purchase_order: Link to a PurchaseOrder (if this stock item was created from a PurchaseOrder) infinite: If True this StockItem can never be exhausted + active: True (by default) unless the StockItem has been 'deleted' """ def save(self, *args, **kwargs): @@ -357,13 +358,15 @@ class StockItem(models.Model): choices=StockStatus.items(), validators=[MinValueValidator(0)]) - notes = models.CharField(max_length=250, blank=True, help_text='Stock Item Notes') + notes = models.CharField(max_length=250, blank=True, help_text=_('Stock Item Notes')) # If stock item is incoming, an (optional) ETA field # expected_arrival = models.DateField(null=True, blank=True) infinite = models.BooleanField(default=False) + active = models.BooleanField(default=True) + def can_delete(self): """ Can this stock item be deleted? It can NOT be deleted under the following circumstances: