mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add "enabled" field to Label class
- Only list labels which are enabled - Allows labels to be hidden / disabled without being deleted
This commit is contained in:
parent
de86418ede
commit
8f1af0f5f9
@ -8,7 +8,7 @@ from .models import StockItemLabel
|
||||
|
||||
class StockItemLabelAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('name', 'description', 'label')
|
||||
list_display = ('name', 'description', 'label', 'filters', 'enabled')
|
||||
|
||||
|
||||
admin.site.register(StockItemLabel, StockItemLabelAdmin)
|
||||
|
18
InvenTree/label/migrations/0002_stockitemlabel_enabled.py
Normal file
18
InvenTree/label/migrations/0002_stockitemlabel_enabled.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.7 on 2020-08-22 23:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('label', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='stockitemlabel',
|
||||
name='enabled',
|
||||
field=models.BooleanField(default=True, help_text='Label template is enabled', verbose_name='Enabled'),
|
||||
),
|
||||
]
|
@ -70,6 +70,12 @@ class LabelTemplate(models.Model):
|
||||
validators=[validateFilterString]
|
||||
)
|
||||
|
||||
enabled = models.BooleanField(
|
||||
default=True,
|
||||
help_text=_('Label template is enabled'),
|
||||
verbose_name=_('Enabled')
|
||||
)
|
||||
|
||||
def get_record_data(self, items):
|
||||
"""
|
||||
Return a list of dict objects, one for each item.
|
||||
|
@ -310,7 +310,8 @@ class StockItemSelectLabels(AjaxView):
|
||||
|
||||
labels = []
|
||||
|
||||
for label in StockItemLabel.objects.all():
|
||||
# Construct a list of StockItemLabel objects which are enabled, and the filters match the selected StockItem
|
||||
for label in StockItemLabel.objects.filter(enabled=True):
|
||||
if label.matches_stock_item(item):
|
||||
labels.append(label)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user