InvenTree/InvenTree/part/forms.py

71 lines
1.7 KiB
Python
Raw Normal View History

from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from .models import Part, PartCategory, BomItem
class EditPartForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EditPartForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-edit-part-form'
self.helper.form_method = 'post'
self.helper.add_input(Submit('submit', 'Submit'))
class Meta:
model = Part
fields = [
'category',
'name',
'description',
'IPN',
'URL',
'minimum_stock',
'trackable',
'purchaseable',
]
class EditCategoryForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EditCategoryForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-edit-part-form'
self.helper.form_method = 'post'
self.helper.add_input(Submit('submit', 'Submit'))
class Meta:
model = PartCategory
fields = [
'parent',
'name',
'description'
]
class EditBomItemForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EditBomItemForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-edit-part-form'
self.helper.form_method = 'post'
2018-04-15 15:02:17 +00:00
self.helper.add_input(Submit('submit', 'Submit'))
class Meta:
model = BomItem
fields = [
'part',
'sub_part',
'quantity'
2018-04-15 15:02:17 +00:00
]