Add default values for create part form

This commit is contained in:
Oliver Walters 2020-11-09 22:52:32 +11:00
parent 8149759852
commit e1b70ff68f
3 changed files with 15 additions and 4 deletions

View File

@ -174,7 +174,9 @@ class SetPartCategoryForm(forms.Form):
class EditPartForm(HelperForm):
""" Form for editing a Part object """
"""
Form for editing a Part object.
"""
field_prefix = {
'keywords': 'fa-key',
@ -202,14 +204,14 @@ class EditPartForm(HelperForm):
class Meta:
model = Part
fields = [
'bom_copy',
'parameters_copy',
'confirm_creation',
'category',
'name',
'IPN',
'description',
'revision',
'bom_copy',
'parameters_copy',
'confirm_creation',
'keywords',
'variant_of',
'link',
@ -217,6 +219,9 @@ class EditPartForm(HelperForm):
'default_supplier',
'units',
'minimum_stock',
'trackable',
'purchaseable',
'salable',
]

View File

@ -203,6 +203,7 @@
<td><i>{% trans "Part cannot be sold to customers" %}</i></td>
{% endif %}
</tr>
<tr><td colspan='4'></td></tr>
<tr>
<td>
{% if part.active %}

View File

@ -700,6 +700,11 @@ class PartCreate(AjaxCreateView):
if label in self.request.GET:
initials[label] = self.request.GET.get(label)
# Default values for part options
initials['purchaseable'] = str2bool(InvenTreeSetting.get_setting('PART_PURCHASEABLE'))
initials['salable'] = str2bool(InvenTreeSetting.get_setting('PART_SALABLE'))
initials['trackable'] = str2bool(InvenTreeSetting.get_setting('PART_TRACKABLE'))
return initials