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

Provide form for user to select export options

This commit is contained in:
Oliver Walters
2020-02-11 21:43:17 +11:00
parent eecc435c02
commit 434d084371
7 changed files with 88 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ Django Forms for interacting with Part objects
from __future__ import unicode_literals
from InvenTree.forms import HelperForm
from InvenTree.helpers import GetExportFormats
from mptt.fields import TreeNodeChoiceField
from django import forms
@@ -28,6 +29,26 @@ class PartImageForm(HelperForm):
]
class BomExportForm(forms.Form):
""" Simple form to let user set BOM export options,
before exporting a BOM (bill of materials) file.
"""
file_format = forms.ChoiceField(label=_("File Format"), help_text=_("Select output file format"))
cascading = forms.BooleanField(label=_("Cascading"), required=False, initial=False, help_text=_("Download cascading / multi-level BOM"))
def get_choices(self):
""" BOM export format choices """
return [(x, x.upper()) for x in GetExportFormats()]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['file_format'].choices = self.get_choices()
class BomValidateForm(HelperForm):
""" Simple confirmation form for BOM validation.
User is presented with a single checkbox input,