diff --git a/InvenTree/company/forms.py b/InvenTree/company/forms.py index 003cfaf495..ac3cc69c99 100644 --- a/InvenTree/company/forms.py +++ b/InvenTree/company/forms.py @@ -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 = [ diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index 332e9b6611..4d70ab927a 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -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 = [ diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index 22c302c859..4eaff44b74 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -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,24 +108,27 @@ class SerializeStockForm(HelperForm): def __init__(self, *args, **kwargs): # Extract the stock item - item = kwargs.pop('item') + item = kwargs.pop('item', None) - # Pre-calculate what the serial numbers should be! - sn = item.part.get_next_serial_number() + if item: - if item.quantity >= 2: - sn = "{n}-{m}".format(n=sn, m=int(sn+item.quantity-1)) - else: - sn = str(sn) + # Pre-calculate what the serial numbers should be! + sn = item.part.get_next_serial_number() + + 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 = { 'serial_numbers': 'fa-hashtag', } - self.field_placeholder = { - 'serial_numbers': sn - } - super().__init__(*args, **kwargs) class Meta: diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index c33af4e15a..a7195a5300 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -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 diff --git a/InvenTree/templates/table_filters.html b/InvenTree/templates/table_filters.html index b337b25ac8..de0b049d57 100644 --- a/InvenTree/templates/table_filters.html +++ b/InvenTree/templates/table_filters.html @@ -110,6 +110,10 @@ function getAvailableTableFilters(tableKey) { type: 'bool', title: '{% trans "Salable" %}', }, + trackable: { + type: 'bool', + title: '{% trans "Trackable" %}', + }, purchaseable: { type: 'bool', title: '{% trans "Purchasable" %}',