Remove BuildAutoAllocate form

This commit is contained in:
Oliver 2021-10-05 00:40:10 +11:00
parent 416ba51e22
commit 40f1ccf9f8
4 changed files with 0 additions and 117 deletions

View File

@ -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

View File

@ -1,43 +0,0 @@
{% extends "modal_form.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block pre_form_content %}
{{ block.super }}
<div class='alert alert-block alert-info'>
<strong>{% trans "Automatically Allocate Stock" %}</strong><br>
{% trans "The following stock items will be allocated to the specified build output" %}
</div>
{% if allocations %}
<table class='table table-striped table-condensed'>
<tr>
<th></th>
<th>{% trans "Part" %}</th>
<th>{% trans "Quantity" %}</th>
<th>{% trans "Location" %}</th>
</tr>
{% for item in allocations %}
<tr>
<td>
{% include "hover_image.html" with image=item.stock_item.part.image hover=True %}
</td>
<td>
{{ item.stock_item.part.full_name }}<br>
<em>{{ item.stock_item.part.description }}</em>
</td>
<td>{% decimal item.quantity %}</td>
<td>{{ item.stock_item.location }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<div class='alert alert-block alert-warning'>
{% trans "No stock items found that can be automatically allocated to this build" %}
<br>
{% trans "Stock items will have to be manually allocated" %}
</div>
{% endif %}
{% endblock %}

View File

@ -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'),

View File

@ -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.