Add new field "active" to StockItem model

- True by default
- Set to 'false' to mark a stockitem as 'deleted'
This commit is contained in:
Oliver Walters 2019-11-16 19:41:36 +11:00
parent 56255a98d8
commit 339126b27a
2 changed files with 22 additions and 1 deletions

View File

@ -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),
),
]

View File

@ -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: