2018-04-14 15:18:12 +00:00
|
|
|
from django import forms
|
|
|
|
from crispy_forms.helper import FormHelper
|
|
|
|
|
2018-04-15 11:29:24 +00:00
|
|
|
from .models import Part, PartCategory, BomItem
|
2018-04-22 11:54:12 +00:00
|
|
|
from .models import SupplierPart
|
2018-04-14 15:18:12 +00:00
|
|
|
|
|
|
|
|
2018-04-29 02:25:07 +00:00
|
|
|
class PartImageForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
|
|
|
super(PartImageForm, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
self.helper = FormHelper()
|
|
|
|
self.helper.form_tag = False
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Part
|
|
|
|
fields = [
|
|
|
|
'image',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-04-14 15:18:12 +00:00
|
|
|
class EditPartForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditPartForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
2018-04-26 08:22:41 +00:00
|
|
|
self.helper.form_tag = False
|
2018-04-14 15:18:12 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Part
|
|
|
|
fields = [
|
|
|
|
'category',
|
|
|
|
'name',
|
|
|
|
'description',
|
|
|
|
'IPN',
|
|
|
|
'URL',
|
2018-04-17 08:23:24 +00:00
|
|
|
'default_location',
|
|
|
|
'default_supplier',
|
2018-04-14 15:18:12 +00:00
|
|
|
'minimum_stock',
|
2018-04-16 12:13:31 +00:00
|
|
|
'buildable',
|
2018-04-14 15:18:12 +00:00
|
|
|
'trackable',
|
2018-04-15 14:30:57 +00:00
|
|
|
'purchaseable',
|
2018-04-17 08:11:34 +00:00
|
|
|
'salable',
|
2018-04-17 15:44:55 +00:00
|
|
|
'notes',
|
2018-04-15 01:40:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class EditCategoryForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditCategoryForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
2018-04-25 02:46:58 +00:00
|
|
|
self.helper.form_tag = False
|
2018-04-15 01:40:03 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PartCategory
|
|
|
|
fields = [
|
|
|
|
'parent',
|
|
|
|
'name',
|
|
|
|
'description'
|
2018-04-15 11:29:24 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class EditBomItemForm(forms.ModelForm):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditBomItemForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
|
|
|
self.helper.form_method = 'post'
|
2018-04-16 12:13:31 +00:00
|
|
|
|
2018-04-25 23:26:43 +00:00
|
|
|
self.helper.form_tag = False
|
2018-04-15 11:29:24 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = BomItem
|
|
|
|
fields = [
|
|
|
|
'part',
|
|
|
|
'sub_part',
|
|
|
|
'quantity'
|
2018-04-15 15:02:17 +00:00
|
|
|
]
|
2018-04-22 11:54:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EditSupplierPartForm(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(EditSupplierPartForm, self).__init__(*args, **kwargs)
|
|
|
|
self.helper = FormHelper()
|
|
|
|
|
2018-04-27 11:32:48 +00:00
|
|
|
self.helper.form_tag = False
|
2018-04-22 11:54:12 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SupplierPart
|
|
|
|
fields = [
|
|
|
|
'supplier',
|
|
|
|
'SKU',
|
|
|
|
'part',
|
|
|
|
'description',
|
|
|
|
'URL',
|
|
|
|
'manufacturer',
|
|
|
|
'MPN',
|
|
|
|
]
|