mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	remove code which is now unused
This commit is contained in:
		| @@ -14,51 +14,6 @@ from InvenTree.forms import HelperForm | ||||
| from .models import Build | ||||
|  | ||||
|  | ||||
| class BuildOutputCreateForm(HelperForm): | ||||
|     """ | ||||
|     Form for creating a new build output. | ||||
|     """ | ||||
|  | ||||
|     def __init__(self, *args, **kwargs): | ||||
|  | ||||
|         build = kwargs.pop('build', None) | ||||
|  | ||||
|         if build: | ||||
|             self.field_placeholder['serial_numbers'] = build.part.getSerialNumberString() | ||||
|  | ||||
|         super().__init__(*args, **kwargs) | ||||
|  | ||||
|     field_prefix = { | ||||
|         'serial_numbers': 'fa-hashtag', | ||||
|     } | ||||
|  | ||||
|     output_quantity = forms.IntegerField( | ||||
|         label=_('Quantity'), | ||||
|         help_text=_('Enter quantity for build output'), | ||||
|     ) | ||||
|  | ||||
|     serial_numbers = forms.CharField( | ||||
|         label=_('Serial Numbers'), | ||||
|         required=False, | ||||
|         help_text=_('Enter serial numbers for build outputs'), | ||||
|     ) | ||||
|  | ||||
|     confirm = forms.BooleanField( | ||||
|         required=True, | ||||
|         label=_('Confirm'), | ||||
|         help_text=_('Confirm creation of build output'), | ||||
|     ) | ||||
|  | ||||
|     class Meta: | ||||
|         model = Build | ||||
|         fields = [ | ||||
|             'output_quantity', | ||||
|             'batch', | ||||
|             'serial_numbers', | ||||
|             'confirm', | ||||
|         ] | ||||
|  | ||||
|  | ||||
| class CancelBuildForm(HelperForm): | ||||
|     """ Form for cancelling a build """ | ||||
|  | ||||
|   | ||||
| @@ -1,20 +0,0 @@ | ||||
| {% extends "modal_form.html" %} | ||||
| {% load i18n %} | ||||
| {% block pre_form_content %} | ||||
|  | ||||
| {% if build.part.has_trackable_parts %} | ||||
| <div class='alert alert-block alert-warning'> | ||||
|     {% trans "The Bill of Materials contains trackable parts" %}<br> | ||||
|     {% trans "Build outputs must be generated individually." %}<br> | ||||
|     {% trans "Multiple build outputs will be created based on the quantity specified." %} | ||||
| </div> | ||||
| {% endif %} | ||||
|  | ||||
| {% if build.part.trackable %} | ||||
| <div class='alert alert-block alert-info'> | ||||
|     {% trans "Trackable parts can have serial numbers specified" %}<br> | ||||
|     {% trans "Enter serial numbers to generate multiple single build outputs" %} | ||||
| </div> | ||||
| {% endif %} | ||||
|  | ||||
| {% endblock %} | ||||
| @@ -328,13 +328,6 @@ $('#btn-create-output').click(function() { | ||||
|             trackable_parts: {% if build.part.has_trackable_parts %}true{% else %}false{% endif%}, | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     return; | ||||
|     launchModalForm('{% url "build-output-create" build.id %}', | ||||
|         { | ||||
|             reload: true, | ||||
|         } | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| loadStockTable($("#build-stock-table"), { | ||||
|   | ||||
| @@ -9,7 +9,6 @@ from . import views | ||||
| build_detail_urls = [ | ||||
|     url(r'^cancel/', views.BuildCancel.as_view(), name='build-cancel'), | ||||
|     url(r'^delete/', views.BuildDelete.as_view(), name='build-delete'), | ||||
|     url(r'^create-output/', views.BuildOutputCreate.as_view(), name='build-output-create'), | ||||
|  | ||||
|     url(r'^.*$', views.BuildDetail.as_view(), name='build-detail'), | ||||
| ] | ||||
|   | ||||
| @@ -76,121 +76,6 @@ class BuildCancel(AjaxUpdateView): | ||||
|         } | ||||
|  | ||||
|  | ||||
| class BuildOutputCreate(AjaxUpdateView): | ||||
|     """ | ||||
|     Create a new build output (StockItem) for a given build. | ||||
|     """ | ||||
|  | ||||
|     model = Build | ||||
|     form_class = forms.BuildOutputCreateForm | ||||
|     ajax_template_name = 'build/build_output_create.html' | ||||
|     ajax_form_title = _('Create Build Output') | ||||
|  | ||||
|     def validate(self, build, form, **kwargs): | ||||
|         """ | ||||
|         Validation for the form: | ||||
|         """ | ||||
|  | ||||
|         quantity = form.cleaned_data.get('output_quantity', None) | ||||
|         serials = form.cleaned_data.get('serial_numbers', None) | ||||
|  | ||||
|         if quantity is not None: | ||||
|             build = self.get_object() | ||||
|  | ||||
|             # Check that requested output don't exceed build remaining quantity | ||||
|             maximum_output = int(build.remaining - build.incomplete_count) | ||||
|  | ||||
|             if quantity > maximum_output: | ||||
|                 form.add_error( | ||||
|                     'output_quantity', | ||||
|                     _('Maximum output quantity is ') + str(maximum_output), | ||||
|                 ) | ||||
|  | ||||
|             elif quantity <= 0: | ||||
|                 form.add_error( | ||||
|                     'output_quantity', | ||||
|                     _('Output quantity must be greater than zero'), | ||||
|                 ) | ||||
|  | ||||
|         # Check that the serial numbers are valid | ||||
|         if serials: | ||||
|             try: | ||||
|                 extracted = extract_serial_numbers(serials, quantity, build.part.getLatestSerialNumberInt()) | ||||
|  | ||||
|                 if extracted: | ||||
|                     # Check for conflicting serial numbers | ||||
|                     conflicts = build.part.find_conflicting_serial_numbers(extracted) | ||||
|  | ||||
|                     if len(conflicts) > 0: | ||||
|                         msg = ",".join([str(c) for c in conflicts]) | ||||
|                         form.add_error( | ||||
|                             'serial_numbers', | ||||
|                             _('Serial numbers already exist') + ': ' + msg, | ||||
|                         ) | ||||
|  | ||||
|             except ValidationError as e: | ||||
|                 form.add_error('serial_numbers', e.messages) | ||||
|  | ||||
|         else: | ||||
|             # If no serial numbers are provided, should they be? | ||||
|             if build.part.trackable: | ||||
|                 form.add_error('serial_numbers', _('Serial numbers required for trackable build output')) | ||||
|  | ||||
|     def save(self, build, form, **kwargs): | ||||
|         """ | ||||
|         Create a new build output | ||||
|         """ | ||||
|  | ||||
|         data = form.cleaned_data | ||||
|  | ||||
|         quantity = data.get('output_quantity', None) | ||||
|         batch = data.get('batch', None) | ||||
|  | ||||
|         serials = data.get('serial_numbers', None) | ||||
|  | ||||
|         if serials: | ||||
|             serial_numbers = extract_serial_numbers(serials, quantity, build.part.getLatestSerialNumberInt()) | ||||
|         else: | ||||
|             serial_numbers = None | ||||
|  | ||||
|         build.create_build_output( | ||||
|             quantity, | ||||
|             serials=serial_numbers, | ||||
|             batch=batch, | ||||
|         ) | ||||
|  | ||||
|     def get_initial(self): | ||||
|  | ||||
|         initials = super().get_initial() | ||||
|  | ||||
|         build = self.get_object() | ||||
|  | ||||
|         # Calculate the required quantity | ||||
|         quantity = max(0, build.remaining - build.incomplete_count) | ||||
|         initials['output_quantity'] = int(quantity) | ||||
|  | ||||
|         return initials | ||||
|  | ||||
|     def get_form(self): | ||||
|  | ||||
|         build = self.get_object() | ||||
|         part = build.part | ||||
|  | ||||
|         context = self.get_form_kwargs() | ||||
|  | ||||
|         # Pass the 'part' through to the form, | ||||
|         # so we can add the next serial number as a placeholder | ||||
|         context['build'] = build | ||||
|  | ||||
|         form = self.form_class(**context) | ||||
|  | ||||
|         # If the part is not trackable, hide the serial number input | ||||
|         if not part.trackable: | ||||
|             form.fields['serial_numbers'].widget = HiddenInput() | ||||
|  | ||||
|         return form | ||||
|  | ||||
|  | ||||
| class BuildDetail(InvenTreeRoleMixin, DetailView): | ||||
|     """ | ||||
|     Detail view of a single Build object. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user