2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-15 08:48:11 +00:00

Add form for selecting label template for a StockItem

This commit is contained in:
Oliver Walters
2020-08-16 12:10:58 +10:00
parent 30e24f19d9
commit 1807ba4e7b
5 changed files with 95 additions and 0 deletions

View File

@@ -178,6 +178,37 @@ class SerializeStockForm(HelperForm):
]
class StockItemLabelSelectForm(HelperForm):
""" Form for selecting a label template for a StockItem """
label = forms.ChoiceField(
label=_('Label'),
help_text=_('Select test report template')
)
class Meta:
model = StockItem
fields = [
'label',
]
def get_label_choices(self, labels):
choices = []
if len(labels) > 0:
for label in labels:
choices.append((label.pk, label))
return choices
def __init__(self, labels, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['label'].choices = self.get_label_choices(labels)
class TestReportFormatForm(HelperForm):
""" Form for selection a test report template """