diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 7078b37b5a..f03686cb41 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -340,7 +340,6 @@ class Build(MPTTModel): # which point to thie Build Order self.allocated_stock.all().delete() - @transaction.atomic def cancelBuild(self, user): """ Mark the Build as CANCELLED @@ -503,7 +502,7 @@ class Build(MPTTModel): else: serial = None - output = StockModels.StockItem.objects.create( + StockModels.StockItem.objects.create( quantity=1, location=location, part=self.part, @@ -518,7 +517,7 @@ class Build(MPTTModel): Create a single build output of the given quantity """ - output = StockModels.StockItem.objects.create( + StockModels.StockItem.objects.create( quantity=quantity, location=location, part=self.part, @@ -527,7 +526,6 @@ class Build(MPTTModel): is_building=True ) - @transaction.atomic def deleteBuildOutput(self, output): """ @@ -602,7 +600,6 @@ class Build(MPTTModel): # REF: https://www.botreetechnologies.com/blog/implementing-celery-using-django-for-background-task-processing # REF: https://code.tutsplus.com/tutorials/using-celery-with-django-for-background-task-processing--cms-28732 - # Complete the allocation of stock for that item build_item.complete_allocation(user) diff --git a/InvenTree/build/templates/build/allocation_card.html b/InvenTree/build/templates/build/allocation_card.html index 4bc220d807..650257bb0d 100644 --- a/InvenTree/build/templates/build/allocation_card.html +++ b/InvenTree/build/templates/build/allocation_card.html @@ -16,7 +16,7 @@ {% if item.serial %} # {{ item.serial }} {% else %} - {{ item.quantity }} + {% decimal item.quantity %} {% endif %} diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index b5aa41e6a0..30a2b1d694 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -240,7 +240,6 @@ class BuildOutputCreate(AjaxUpdateView): batch=batch, ) - def get_initial(self): initials = super().get_initial() @@ -262,7 +261,7 @@ class BuildOutputCreate(AjaxUpdateView): # If the part is not trackable, hide the serial number input if not part.trackable: - form.fields['serial_numbers'] = HiddenInput() + form.fields['serial_numbers'].widget = HiddenInput() return form @@ -655,11 +654,7 @@ class BuildCreate(AjaxCreateView): form = super().get_form() if form['part'].value(): - part = Part.objects.get(pk=form['part'].value()) - - # Part is not trackable - hide serial numbers - if not part.trackable: - form.fields['serial_numbers'].widget = HiddenInput() + form.fields['part'].widget = HiddenInput() return form @@ -699,7 +694,7 @@ class BuildCreate(AjaxCreateView): 'success': _('Created new build'), } - def validate(self, request, form, cleaned_data, **kwargs): + def validate(self, build, form, **kwargs): """ Perform extra form validation. @@ -708,34 +703,7 @@ class BuildCreate(AjaxCreateView): By this point form.is_valid() has been executed """ - part = cleaned_data['part'] - - if part.trackable: - # For a trackable part, either batch or serial nubmber must be specified - if not cleaned_data['serial_numbers']: - form.add_error('serial_numbers', _('Trackable part must have serial numbers specified')) - else: - # If serial numbers are set... - serials = cleaned_data['serial_numbers'] - quantity = cleaned_data['quantity'] - - # Check that the provided serial numbers are sensible - try: - extracted = extract_serial_numbers(serials, quantity) - except ValidationError as e: - extracted = None - form.add_error('serial_numbers', e.messages) - - if extracted: - # Check that the provided serial numbers are not duplicates - conflicts = 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 - ) + pass class BuildUpdate(AjaxUpdateView): diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index 1fa4b1931f..38d07cb00e 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -10,7 +10,8 @@ {% include 'part/tabs.html' with tab='bom' %} -