From 40f1ccf9f8c56bc24c268f29f9e15434f08e64c7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 5 Oct 2021 00:40:10 +1100 Subject: [PATCH] Remove BuildAutoAllocate form --- InvenTree/build/forms.py | 12 ---- .../build/templates/build/auto_allocate.html | 43 ------------- InvenTree/build/urls.py | 1 - InvenTree/build/views.py | 61 ------------------- 4 files changed, 117 deletions(-) delete mode 100644 InvenTree/build/templates/build/auto_allocate.html diff --git a/InvenTree/build/forms.py b/InvenTree/build/forms.py index e2ca7c3f75..47c9b8612c 100644 --- a/InvenTree/build/forms.py +++ b/InvenTree/build/forms.py @@ -163,18 +163,6 @@ class UnallocateBuildForm(HelperForm): ] -class AutoAllocateForm(HelperForm): - """ Form for auto-allocation of stock to a build """ - - confirm = forms.BooleanField(required=True, label=_('Confirm'), help_text=_('Confirm stock allocation')) - - class Meta: - model = Build - fields = [ - 'confirm', - ] - - class CompleteBuildForm(HelperForm): """ Form for marking a build as complete diff --git a/InvenTree/build/templates/build/auto_allocate.html b/InvenTree/build/templates/build/auto_allocate.html deleted file mode 100644 index 2f2c7bbca7..0000000000 --- a/InvenTree/build/templates/build/auto_allocate.html +++ /dev/null @@ -1,43 +0,0 @@ -{% extends "modal_form.html" %} -{% load i18n %} -{% load inventree_extras %} -{% block pre_form_content %} - -{{ block.super }} - -
- {% trans "Automatically Allocate Stock" %}
- {% trans "The following stock items will be allocated to the specified build output" %} -
-{% if allocations %} - - - - - - - -{% for item in allocations %} - - - - - - -{% endfor %} -
{% trans "Part" %}{% trans "Quantity" %}{% trans "Location" %}
- {% include "hover_image.html" with image=item.stock_item.part.image hover=True %} - - {{ item.stock_item.part.full_name }}
- {{ item.stock_item.part.description }} -
{% decimal item.quantity %}{{ item.stock_item.location }}
- -{% else %} -
- {% trans "No stock items found that can be automatically allocated to this build" %} -
- {% trans "Stock items will have to be manually allocated" %} -
-{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/build/urls.py b/InvenTree/build/urls.py index e7e6ddb5e2..050c32209b 100644 --- a/InvenTree/build/urls.py +++ b/InvenTree/build/urls.py @@ -12,7 +12,6 @@ build_detail_urls = [ 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'^auto-allocate/', views.BuildAutoAllocate.as_view(), name='build-auto-allocate'), url(r'^unallocate/', views.BuildUnallocate.as_view(), name='build-unallocate'), url(r'^complete/', views.BuildComplete.as_view(), name='build-complete'), diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 7c92fa1846..a66c38d62b 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -77,67 +77,6 @@ class BuildCancel(AjaxUpdateView): } -class BuildAutoAllocate(AjaxUpdateView): - """ View to auto-allocate parts for a build. - Follows a simple set of rules to automatically allocate StockItem objects. - - Ref: build.models.Build.getAutoAllocations() - """ - - model = Build - form_class = forms.AutoAllocateForm - context_object_name = 'build' - ajax_form_title = _('Allocate Stock') - ajax_template_name = 'build/auto_allocate.html' - - def get_initial(self): - """ - Initial values for the form. - """ - - initials = super().get_initial() - - return initials - - def get_context_data(self, *args, **kwargs): - """ - Get the context data for form rendering. - """ - - context = {} - - build = self.get_object() - - context['allocations'] = build.getAutoAllocations() - - context['build'] = build - - return context - - def get_form(self): - - form = super().get_form() - - return form - - def validate(self, build, form, **kwargs): - - pass - - def save(self, build, form, **kwargs): - """ - Once the form has been validated, - perform auto-allocations - """ - - build.autoAllocate() - - def get_data(self): - return { - 'success': _('Allocated stock to build output'), - } - - class BuildOutputCreate(AjaxUpdateView): """ Create a new build output (StockItem) for a given build.