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):
|
class EditCompanyForm(HelperForm):
|
||||||
""" Form for editing a Company object """
|
""" 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:
|
class Meta:
|
||||||
model = Company
|
model = Company
|
||||||
fields = [
|
fields = [
|
||||||
@ -45,6 +53,13 @@ class CompanyImageForm(HelperForm):
|
|||||||
class EditSupplierPartForm(HelperForm):
|
class EditSupplierPartForm(HelperForm):
|
||||||
""" Form for editing a SupplierPart object """
|
""" Form for editing a SupplierPart object """
|
||||||
|
|
||||||
|
field_prefix = {
|
||||||
|
'link': 'fa-link',
|
||||||
|
'MPN': 'fa-hashtag',
|
||||||
|
'SKU': 'fa-hashtag',
|
||||||
|
'note': 'fa-pencil-alt',
|
||||||
|
}
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -97,6 +97,12 @@ class SetPartCategoryForm(forms.Form):
|
|||||||
class EditPartForm(HelperForm):
|
class EditPartForm(HelperForm):
|
||||||
""" Form for editing a Part object """
|
""" Form for editing a Part object """
|
||||||
|
|
||||||
|
field_prefix = {
|
||||||
|
'keywords': 'fa-key',
|
||||||
|
'link': 'fa-link',
|
||||||
|
'IPN': 'fa-hashtag',
|
||||||
|
}
|
||||||
|
|
||||||
deep_copy = forms.BooleanField(required=False,
|
deep_copy = forms.BooleanField(required=False,
|
||||||
initial=True,
|
initial=True,
|
||||||
help_text=_("Perform 'deep copy' which will duplicate all BOM data for this part"),
|
help_text=_("Perform 'deep copy' which will duplicate all BOM data for this part"),
|
||||||
@ -155,6 +161,10 @@ class EditPartParameterForm(HelperForm):
|
|||||||
class EditCategoryForm(HelperForm):
|
class EditCategoryForm(HelperForm):
|
||||||
""" Form for editing a PartCategory object """
|
""" Form for editing a PartCategory object """
|
||||||
|
|
||||||
|
field_prefix = {
|
||||||
|
'default_keywords': 'fa-key',
|
||||||
|
}
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PartCategory
|
model = PartCategory
|
||||||
fields = [
|
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)'))
|
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:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
fields = [
|
fields = [
|
||||||
@ -74,6 +83,7 @@ class CreateStockItemForm(HelperForm):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.cleaned_data = {}
|
self.cleaned_data = {}
|
||||||
|
|
||||||
# If the form is permitted to be empty, and none of the form data has
|
# If the form is permitted to be empty, and none of the form data has
|
||||||
# changed from the initial data, short circuit any validation.
|
# changed from the initial data, short circuit any validation.
|
||||||
if self.empty_permitted and not self.has_changed():
|
if self.empty_permitted and not self.has_changed():
|
||||||
@ -98,24 +108,27 @@ class SerializeStockForm(HelperForm):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
# Extract the stock item
|
# Extract the stock item
|
||||||
item = kwargs.pop('item')
|
item = kwargs.pop('item', None)
|
||||||
|
|
||||||
# Pre-calculate what the serial numbers should be!
|
if item:
|
||||||
sn = item.part.get_next_serial_number()
|
|
||||||
|
|
||||||
if item.quantity >= 2:
|
# Pre-calculate what the serial numbers should be!
|
||||||
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
sn = item.part.get_next_serial_number()
|
||||||
else:
|
|
||||||
sn = str(sn)
|
if item.quantity >= 2:
|
||||||
|
sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1))
|
||||||
|
else:
|
||||||
|
sn = str(sn)
|
||||||
|
|
||||||
|
|
||||||
|
self.field_placeholder = {
|
||||||
|
'serial_numbers': sn
|
||||||
|
}
|
||||||
|
|
||||||
self.field_prefix = {
|
self.field_prefix = {
|
||||||
'serial_numbers': 'fa-hashtag',
|
'serial_numbers': 'fa-hashtag',
|
||||||
}
|
}
|
||||||
|
|
||||||
self.field_placeholder = {
|
|
||||||
'serial_numbers': sn
|
|
||||||
}
|
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -937,6 +937,7 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
if part_id:
|
if part_id:
|
||||||
try:
|
try:
|
||||||
part = Part.objects.get(pk=part_id)
|
part = Part.objects.get(pk=part_id)
|
||||||
|
|
||||||
# Check that the supplied part is 'valid'
|
# Check that the supplied part is 'valid'
|
||||||
if not part.is_template and part.active and not part.virtual:
|
if not part.is_template and part.active and not part.virtual:
|
||||||
initials['part'] = part
|
initials['part'] = part
|
||||||
|
@ -110,6 +110,10 @@ function getAvailableTableFilters(tableKey) {
|
|||||||
type: 'bool',
|
type: 'bool',
|
||||||
title: '{% trans "Salable" %}',
|
title: '{% trans "Salable" %}',
|
||||||
},
|
},
|
||||||
|
trackable: {
|
||||||
|
type: 'bool',
|
||||||
|
title: '{% trans "Trackable" %}',
|
||||||
|
},
|
||||||
purchaseable: {
|
purchaseable: {
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
title: '{% trans "Purchasable" %}',
|
title: '{% trans "Purchasable" %}',
|
||||||
|
Loading…
Reference in New Issue
Block a user