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
|
2018-04-14 15:18:12 +00:00
|
|
|
|
2019-04-13 12:46:26 +00:00
|
|
|
from django import forms
|
|
|
|
|
2019-05-02 07:29:21 +00:00
|
|
|
from .models import Part, PartCategory, PartAttachment
|
|
|
|
from .models import BomItem
|
2018-04-22 11:54:12 +00:00
|
|
|
from .models import SupplierPart
|
2018-04-14 15:18:12 +00:00
|
|
|
|
|
|
|
|
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',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-04-13 12:46:26 +00:00
|
|
|
class BomExportForm(HelperForm):
|
|
|
|
|
|
|
|
# TODO - Define these choices somewhere else, and import them here
|
|
|
|
format_choices = (
|
|
|
|
('csv', 'CSV'),
|
|
|
|
('pdf', 'PDF'),
|
2019-04-16 11:46:12 +00:00
|
|
|
('xml', 'XML'),
|
|
|
|
('xlsx', 'XLSX'),
|
|
|
|
('html', 'HTML')
|
2019-04-13 12:46:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# 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 = [
|
2019-04-16 11:46:12 +00:00
|
|
|
'format',
|
2019-04-13 12:46:26 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-05-02 07:29:21 +00:00
|
|
|
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 """
|
2018-04-14 15:18:12 +00:00
|
|
|
|
2019-05-11 02:29:02 +00:00
|
|
|
confirm_creation = forms.BooleanField(required=False, initial=False, help_text='Confirm part creation', widget=forms.HiddenInput())
|
|
|
|
|
2018-04-14 15:18:12 +00:00
|
|
|
class Meta:
|
|
|
|
model = Part
|
|
|
|
fields = [
|
2019-05-11 02:29:02 +00:00
|
|
|
'confirm_creation',
|
2018-04-14 15:18:12 +00:00
|
|
|
'category',
|
|
|
|
'name',
|
2019-05-10 12:17:13 +00:00
|
|
|
'variant',
|
2018-04-14 15:18:12 +00:00
|
|
|
'description',
|
|
|
|
'IPN',
|
|
|
|
'URL',
|
2018-04-17 08:23:24 +00:00
|
|
|
'default_location',
|
|
|
|
'default_supplier',
|
2019-04-15 14:01:15 +00:00
|
|
|
'units',
|
2018-04-14 15:18:12 +00:00
|
|
|
'minimum_stock',
|
2018-04-16 12:13:31 +00:00
|
|
|
'buildable',
|
2019-04-15 14:01:15 +00:00
|
|
|
'consumable',
|
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
|
|
|
]
|
|
|
|
|
|
|
|
|
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 """
|
2018-04-15 01:40:03 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PartCategory
|
|
|
|
fields = [
|
|
|
|
'parent',
|
|
|
|
'name',
|
2019-05-04 09:03:32 +00:00
|
|
|
'description',
|
|
|
|
'default_location'
|
2018-04-15 11:29:24 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
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 """
|
2018-04-15 11:29:24 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = BomItem
|
|
|
|
fields = [
|
|
|
|
'part',
|
|
|
|
'sub_part',
|
2019-04-15 15:41:01 +00:00
|
|
|
'quantity',
|
|
|
|
'note'
|
2018-04-15 15:02:17 +00:00
|
|
|
]
|
2019-04-27 23:53:42 +00:00
|
|
|
|
|
|
|
# Prevent editing of the part associated with this BomItem
|
2019-04-15 15:41:01 +00:00
|
|
|
widgets = {'part': forms.HiddenInput()}
|
2018-04-22 11:54:12 +00:00
|
|
|
|
|
|
|
|
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 """
|
2018-04-22 11:54:12 +00:00
|
|
|
|
2019-04-24 17:20:25 +00:00
|
|
|
class Meta:
|
|
|
|
model = SupplierPart
|
|
|
|
fields = [
|
2019-04-27 22:55:29 +00:00
|
|
|
'part',
|
2019-04-24 17:20:25 +00:00
|
|
|
'supplier',
|
|
|
|
'SKU',
|
|
|
|
'description',
|
|
|
|
'manufacturer',
|
|
|
|
'MPN',
|
2019-04-27 22:55:29 +00:00
|
|
|
'URL',
|
2019-04-24 17:20:25 +00:00
|
|
|
'note',
|
|
|
|
'single_price',
|
|
|
|
'base_cost',
|
|
|
|
'multiple',
|
|
|
|
'minimum',
|
|
|
|
'packaging',
|
|
|
|
'lead_time'
|
|
|
|
]
|