InvenTree/InvenTree/part/forms.py

138 lines
3.0 KiB
Python
Raw Normal View History

2019-04-27 12:18:07 +00:00
"""
Django Forms for interacting with Part objects
"""
2018-04-29 14:59:36 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from InvenTree.forms import HelperForm
from django import forms
from .models import Part, PartCategory, PartAttachment
from .models import BomItem
from .models import SupplierPart
2018-04-29 14:59:36 +00:00
class PartImageForm(HelperForm):
2019-04-27 12:18:07 +00:00
""" Form for uploading a Part image """
2018-04-29 02:25:07 +00:00
class Meta:
model = Part
fields = [
'image',
]
class BomExportForm(HelperForm):
# TODO - Define these choices somewhere else, and import them here
format_choices = (
('csv', 'CSV'),
('pdf', 'PDF'),
('xml', 'XML'),
('xlsx', 'XLSX'),
('html', 'HTML')
)
# Select export type
format = forms.CharField(label='Format', widget=forms.Select(choices=format_choices), required='true', help_text='Select export format')
class Meta:
model = Part
fields = [
'format',
]
class EditPartAttachmentForm(HelperForm):
""" Form for editing a PartAttachment object """
class Meta:
model = PartAttachment
fields = [
'part',
'attachment',
'comment'
]
2018-04-29 14:59:36 +00:00
class EditPartForm(HelperForm):
2019-04-27 12:18:07 +00:00
""" Form for editing a Part object """
confirm_creation = forms.BooleanField(required=False, initial=False, help_text='Confirm part creation', widget=forms.HiddenInput())
class Meta:
model = Part
fields = [
'confirm_creation',
'category',
'name',
'variant',
'description',
'IPN',
'URL',
'default_location',
'default_supplier',
'units',
'minimum_stock',
'buildable',
'consumable',
'trackable',
'purchaseable',
2018-04-17 08:11:34 +00:00
'salable',
'notes',
]
2018-04-29 14:59:36 +00:00
class EditCategoryForm(HelperForm):
2019-04-27 12:18:07 +00:00
""" Form for editing a PartCategory object """
class Meta:
model = PartCategory
fields = [
'parent',
'name',
'description',
'default_location'
]
2018-04-29 14:59:36 +00:00
class EditBomItemForm(HelperForm):
2019-04-27 12:18:07 +00:00
""" Form for editing a BomItem object """
class Meta:
model = BomItem
fields = [
'part',
'sub_part',
'quantity',
'note'
2018-04-15 15:02:17 +00:00
]
# Prevent editing of the part associated with this BomItem
widgets = {'part': forms.HiddenInput()}
2018-04-29 14:59:36 +00:00
class EditSupplierPartForm(HelperForm):
2019-04-27 12:18:07 +00:00
""" Form for editing a SupplierPart object """
2019-04-24 17:20:25 +00:00
class Meta:
model = SupplierPart
fields = [
'part',
2019-04-24 17:20:25 +00:00
'supplier',
'SKU',
'description',
'manufacturer',
'MPN',
'URL',
2019-04-24 17:20:25 +00:00
'note',
'single_price',
'base_cost',
'multiple',
'minimum',
'packaging',
'lead_time'
]