mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds ability to specify "status" of a build output at time of completion
This commit is contained in:
parent
0722aea58a
commit
9b763ca715
@ -12,6 +12,8 @@ from InvenTree.forms import HelperForm
|
||||
from InvenTree.fields import RoundingDecimalFormField
|
||||
from InvenTree.fields import DatePickerFormField
|
||||
|
||||
from InvenTree.status_codes import StockStatus
|
||||
|
||||
from .models import Build, BuildItem, BuildOrderAttachment
|
||||
|
||||
from stock.models import StockLocation, StockItem
|
||||
@ -208,6 +210,13 @@ class CompleteBuildOutputForm(HelperForm):
|
||||
help_text=_('Location of completed parts'),
|
||||
)
|
||||
|
||||
stock_status = forms.ChoiceField(
|
||||
label=_('Status'),
|
||||
help_text=_('Build output stock status'),
|
||||
initial=StockStatus.OK,
|
||||
choices=StockStatus.items(),
|
||||
)
|
||||
|
||||
confirm_incomplete = forms.BooleanField(
|
||||
required=False,
|
||||
label=_('Confirm incomplete'),
|
||||
@ -226,10 +235,14 @@ class CompleteBuildOutputForm(HelperForm):
|
||||
fields = [
|
||||
'location',
|
||||
'output',
|
||||
'stock_status',
|
||||
'confirm',
|
||||
'confirm_incomplete',
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
class CancelBuildForm(HelperForm):
|
||||
""" Form for cancelling a build """
|
||||
|
@ -22,7 +22,7 @@ from markdownx.models import MarkdownxField
|
||||
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
|
||||
from InvenTree.status_codes import BuildStatus
|
||||
from InvenTree.status_codes import BuildStatus, StockStatus
|
||||
from InvenTree.helpers import increment, getSetting, normalize, MakeBarcode
|
||||
from InvenTree.validators import validate_build_order_reference
|
||||
from InvenTree.models import InvenTreeAttachment
|
||||
@ -810,6 +810,7 @@ class Build(MPTTModel):
|
||||
|
||||
# Select the location for the build output
|
||||
location = kwargs.get('location', self.destination)
|
||||
status = kwargs.get('status', StockStatus.OK)
|
||||
|
||||
# List the allocated BuildItem objects for the given output
|
||||
allocated_items = output.items_to_install.all()
|
||||
@ -829,6 +830,7 @@ class Build(MPTTModel):
|
||||
output.build = self
|
||||
output.is_building = False
|
||||
output.location = location
|
||||
output.status = status
|
||||
|
||||
output.save()
|
||||
|
||||
|
@ -19,7 +19,7 @@ from stock.models import StockLocation, StockItem
|
||||
from InvenTree.views import AjaxUpdateView, AjaxCreateView, AjaxDeleteView
|
||||
from InvenTree.views import InvenTreeRoleMixin
|
||||
from InvenTree.helpers import str2bool, extract_serial_numbers, normalize, isNull
|
||||
from InvenTree.status_codes import BuildStatus
|
||||
from InvenTree.status_codes import BuildStatus, StockStatus
|
||||
|
||||
|
||||
class BuildIndex(InvenTreeRoleMixin, ListView):
|
||||
@ -454,6 +454,11 @@ class BuildOutputComplete(AjaxUpdateView):
|
||||
|
||||
output = data.get('output', None)
|
||||
|
||||
stock_status = data.get('stock_status', StockStatus.OK)
|
||||
|
||||
if int(stock_status) not in StockStatus.keys():
|
||||
form.add_error('status', _('Invalid stock status value selected'))
|
||||
|
||||
if output:
|
||||
|
||||
quantity = data.get('quantity', None)
|
||||
@ -545,12 +550,14 @@ class BuildOutputComplete(AjaxUpdateView):
|
||||
|
||||
location = data.get('location', None)
|
||||
output = data.get('output', None)
|
||||
stock_status = data.get('stock_status', StockStatus.OK)
|
||||
|
||||
# Complete the build output
|
||||
build.completeBuildOutput(
|
||||
output,
|
||||
self.request.user,
|
||||
location=location,
|
||||
status=stock_status,
|
||||
)
|
||||
|
||||
def get_data(self):
|
||||
|
Loading…
Reference in New Issue
Block a user