diff --git a/InvenTree/build/forms.py b/InvenTree/build/forms.py index bc7bdd50f5..f385db7f9c 100644 --- a/InvenTree/build/forms.py +++ b/InvenTree/build/forms.py @@ -155,59 +155,6 @@ class CompleteBuildForm(HelperForm): ] -class CompleteBuildOutputForm(HelperForm): - """ - Form for completing a single build output - """ - - field_prefix = { - 'serial_numbers': 'fa-hashtag', - } - - field_placeholder = { - } - - location = forms.ModelChoiceField( - queryset=StockLocation.objects.all(), - label=_('Location'), - 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'), - help_text=_("Confirm completion with incomplete stock allocation") - ) - - confirm = forms.BooleanField(required=True, label=_('Confirm'), help_text=_('Confirm build completion')) - - output = forms.ModelChoiceField( - queryset=StockItem.objects.all(), # Queryset is narrowed in the view - widget=forms.HiddenInput(), - ) - - class Meta: - model = Build - 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 """ diff --git a/InvenTree/build/templates/build/allocation_card.html b/InvenTree/build/templates/build/allocation_card.html deleted file mode 100644 index 3ce4a52aeb..0000000000 --- a/InvenTree/build/templates/build/allocation_card.html +++ /dev/null @@ -1,51 +0,0 @@ -{% load i18n %} -{% load inventree_extras %} - -{% define item.pk as pk %} - -
- -
-
-
-
-
-
\ No newline at end of file diff --git a/InvenTree/build/templates/build/complete_output.html b/InvenTree/build/templates/build/complete_output.html deleted file mode 100644 index d03885774f..0000000000 --- a/InvenTree/build/templates/build/complete_output.html +++ /dev/null @@ -1,53 +0,0 @@ -{% extends "modal_form.html" %} -{% load inventree_extras %} -{% load i18n %} - -{% block pre_form_content %} - -{% if not build.has_tracked_bom_items %} -{% elif fully_allocated %} -
- {% trans "Stock allocation is complete for this output" %} -
-{% else %} -
-

{% trans "Stock allocation is incomplete" %}

- -
-
- -
-
-
    - {% for part in unallocated_parts %} -
  • - {% include "hover_image.html" with image=part.image %} {{ part }} -
  • - {% endfor %} -
-
-
-
-
-
-{% endif %} - -
-
- {% trans "The following items will be created" %} -
-
- {% include "hover_image.html" with image=build.part.image %} - {% if output.serialized %} - {{ output.part.full_name }} - {% trans "Serial Number" %} {{ output.serial }} - {% else %} - {% decimal output.quantity %} x {{ output.part.full_name }} - {% endif %} -
-
- -{% endblock %} \ No newline at end of file diff --git a/InvenTree/build/urls.py b/InvenTree/build/urls.py index d80b16056c..8ea339ae26 100644 --- a/InvenTree/build/urls.py +++ b/InvenTree/build/urls.py @@ -11,7 +11,6 @@ build_detail_urls = [ url(r'^delete/', views.BuildDelete.as_view(), name='build-delete'), url(r'^create-output/', views.BuildOutputCreate.as_view(), name='build-output-create'), url(r'^delete-output/', views.BuildOutputDelete.as_view(), name='build-output-delete'), - url(r'^complete-output/', views.BuildOutputComplete.as_view(), name='build-output-complete'), url(r'^complete/', views.BuildComplete.as_view(), name='build-complete'), url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'), diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 37ec567f1a..5499b48395 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -278,176 +278,6 @@ class BuildComplete(AjaxUpdateView): } -class BuildOutputComplete(AjaxUpdateView): - """ - View to mark a particular build output as Complete. - - - Notifies the user of which parts will be removed from stock. - - Assignes (tracked) allocated items from stock to the build output - - Deletes pending BuildItem objects - """ - - model = Build - form_class = forms.CompleteBuildOutputForm - context_object_name = "build" - ajax_form_title = _("Complete Build Output") - ajax_template_name = "build/complete_output.html" - - def get_form(self): - - build = self.get_object() - - form = super().get_form() - - # Extract the build output object - output = None - output_id = form['output'].value() - - try: - output = StockItem.objects.get(pk=output_id) - except (ValueError, StockItem.DoesNotExist): - pass - - if output: - if build.isFullyAllocated(output): - form.fields['confirm_incomplete'].widget = HiddenInput() - - return form - - def validate(self, build, form, **kwargs): - """ - Custom validation steps for the BuildOutputComplete" form - """ - - data = form.cleaned_data - - output = data.get('output', None) - - stock_status = data.get('stock_status', StockStatus.OK) - - # Any "invalid" stock status defaults to OK - try: - stock_status = int(stock_status) - except (ValueError): - stock_status = StockStatus.OK - - if int(stock_status) not in StockStatus.keys(): - form.add_error('stock_status', _('Invalid stock status value selected')) - - if output: - - quantity = data.get('quantity', None) - - if quantity and quantity > output.quantity: - form.add_error('quantity', _('Quantity to complete cannot exceed build output quantity')) - - if not build.isFullyAllocated(output): - confirm = str2bool(data.get('confirm_incomplete', False)) - - if not confirm: - form.add_error('confirm_incomplete', _('Confirm completion of incomplete build')) - - else: - form.add_error(None, _('Build output must be specified')) - - def get_initial(self): - """ Get initial form data for the CompleteBuild form - - - If the part being built has a default location, pre-select that location - """ - - initials = super().get_initial() - build = self.get_object() - - if build.part.default_location is not None: - try: - location = StockLocation.objects.get(pk=build.part.default_location.id) - initials['location'] = location - except StockLocation.DoesNotExist: - pass - - output = self.get_param('output', None) - - if output: - try: - output = StockItem.objects.get(pk=output) - except (ValueError, StockItem.DoesNotExist): - output = None - - # Output has not been supplied? Try to "guess" - if not output: - - incomplete = build.get_build_outputs(complete=False) - - if incomplete.count() == 1: - output = incomplete[0] - - if output is not None: - initials['output'] = output - - initials['location'] = build.destination - - return initials - - def get_context_data(self, **kwargs): - """ - Get context data for passing to the rendered form - - - Build information is required - """ - - build = self.get_object() - - context = {} - - # Build object - context['build'] = build - - form = self.get_form() - - output = form['output'].value() - - if output: - try: - output = StockItem.objects.get(pk=output) - context['output'] = output - context['fully_allocated'] = build.isFullyAllocated(output) - context['allocated_parts'] = build.allocatedParts(output) - context['unallocated_parts'] = build.unallocatedParts(output) - except (ValueError, StockItem.DoesNotExist): - pass - - return context - - def save(self, build, form, **kwargs): - - data = form.cleaned_data - - location = data.get('location', None) - output = data.get('output', None) - stock_status = data.get('stock_status', StockStatus.OK) - - # Any "invalid" stock status defaults to OK - try: - stock_status = int(stock_status) - except (ValueError): - stock_status = StockStatus.OK - - # Complete the build output - build.complete_build_output( - output, - self.request.user, - location=location, - status=stock_status, - ) - - def get_data(self): - """ Provide feedback data back to the form """ - return { - 'success': _('Build output completed') - } - - class BuildDetail(InvenTreeRoleMixin, DetailView): """ Detail view of a single Build object. """