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:
@@ -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 """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user