InvenTree/InvenTree/build/forms.py
Oliver Walters 905d78e25c Complete build now works
- Marks build as complete
- Deletes temporary BuildItem objects
- Preselects the part's default_location if there is one
- Creates a new stockitem in the selected location
2019-05-02 00:04:39 +10:00

58 lines
1.2 KiB
Python

"""
Django Forms for interacting with Build objects
"""
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from InvenTree.forms import HelperForm
from django import forms
from .models import Build, BuildItem
from stock.models import StockLocation
class EditBuildForm(HelperForm):
""" Form for editing a Build object.
"""
class Meta:
model = Build
fields = [
'title',
'part',
'quantity',
'batch',
'URL',
'notes',
]
class CompleteBuildForm(HelperForm):
""" Form for marking a Build as complete """
location = forms.ModelChoiceField(
queryset=StockLocation.objects.all(),
help_text='Location of completed parts',
)
confirm = forms.BooleanField(required=False, help_text='Confirm build submission')
class Meta:
model = Build
fields = [
'location',
'confirm'
]
class EditBuildItemForm(HelperForm):
""" Form for adding a new BuildItem to a Build """
class Meta:
model = BuildItem
fields = [
'build',
'stock_item',
'quantity',
]