mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add some more form candy
This commit is contained in:
parent
498ad4162c
commit
4cb97b1340
@ -16,6 +16,14 @@ from .models import SupplierPriceBreak
|
||||
class EditCompanyForm(HelperForm):
|
||||
""" Form for editing a Company object """
|
||||
|
||||
field_prefix = {
|
||||
'website': 'fa-globe-asia',
|
||||
'email': 'fa-at',
|
||||
'address': 'fa-envelope',
|
||||
'contact': 'fa-user-tie',
|
||||
'phone': 'fa-phone',
|
||||
}
|
||||
|
||||
class Meta:
|
||||
model = Company
|
||||
fields = [
|
||||
@ -45,6 +53,13 @@ class CompanyImageForm(HelperForm):
|
||||
class EditSupplierPartForm(HelperForm):
|
||||
""" Form for editing a SupplierPart object """
|
||||
|
||||
field_prefix = {
|
||||
'link': 'fa-link',
|
||||
'MPN': 'fa-hashtag',
|
||||
'SKU': 'fa-hashtag',
|
||||
'note': 'fa-pencil-alt',
|
||||
}
|
||||
|
||||
class Meta:
|
||||
model = SupplierPart
|
||||
fields = [
|
||||
|
@ -97,6 +97,12 @@ class SetPartCategoryForm(forms.Form):
|
||||
class EditPartForm(HelperForm):
|
||||
""" Form for editing a Part object """
|
||||
|
||||
field_prefix = {
|
||||
'keywords': 'fa-key',
|
||||
'link': 'fa-link',
|
||||
'IPN': 'fa-hashtag',
|
||||
}
|
||||
|
||||
deep_copy = forms.BooleanField(required=False,
|
||||
initial=True,
|
||||
help_text=_("Perform 'deep copy' which will duplicate all BOM data for this part"),
|
||||
@ -155,6 +161,10 @@ class EditPartParameterForm(HelperForm):
|
||||
class EditCategoryForm(HelperForm):
|
||||
""" Form for editing a PartCategory object """
|
||||
|
||||
field_prefix = {
|
||||
'default_keywords': 'fa-key',
|
||||
}
|
||||
|
||||
class Meta:
|
||||
model = PartCategory
|
||||
fields = [
|
||||
|
@ -52,6 +52,15 @@ class CreateStockItemForm(HelperForm):
|
||||
|
||||
serial_numbers = forms.CharField(label='Serial numbers', required=False, help_text=_('Enter unique serial numbers (or leave blank)'))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
self.field_prefix = {
|
||||
'serial_numbers': 'fa-hashtag',
|
||||
'link': 'fa-link',
|
||||
}
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = StockItem
|
||||
fields = [
|
||||
@ -74,6 +83,7 @@ class CreateStockItemForm(HelperForm):
|
||||
return
|
||||
|
||||
self.cleaned_data = {}
|
||||
|
||||
# If the form is permitted to be empty, and none of the form data has
|
||||
# changed from the initial data, short circuit any validation.
|
||||
if self.empty_permitted and not self.has_changed():
|
||||
@ -98,7 +108,9 @@ class SerializeStockForm(HelperForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
# Extract the stock item
|
||||
item = kwargs.pop('item')
|
||||
item = kwargs.pop('item', None)
|
||||
|
||||
if item:
|
||||
|
||||
# Pre-calculate what the serial numbers should be!
|
||||
sn = item.part.get_next_serial_number()
|
||||
@ -108,14 +120,15 @@ class SerializeStockForm(HelperForm):
|
||||
else:
|
||||
sn = str(sn)
|
||||
|
||||
self.field_prefix = {
|
||||
'serial_numbers': 'fa-hashtag',
|
||||
}
|
||||
|
||||
self.field_placeholder = {
|
||||
'serial_numbers': sn
|
||||
}
|
||||
|
||||
self.field_prefix = {
|
||||
'serial_numbers': 'fa-hashtag',
|
||||
}
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
|
@ -937,6 +937,7 @@ class StockItemCreate(AjaxCreateView):
|
||||
if part_id:
|
||||
try:
|
||||
part = Part.objects.get(pk=part_id)
|
||||
|
||||
# Check that the supplied part is 'valid'
|
||||
if not part.is_template and part.active and not part.virtual:
|
||||
initials['part'] = part
|
||||
|
@ -110,6 +110,10 @@ function getAvailableTableFilters(tableKey) {
|
||||
type: 'bool',
|
||||
title: '{% trans "Salable" %}',
|
||||
},
|
||||
trackable: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Trackable" %}',
|
||||
},
|
||||
purchaseable: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Purchasable" %}',
|
||||
|
Loading…
Reference in New Issue
Block a user