mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1530 from eeintech/complete_build_output_fix
Fixes to create build output form
This commit is contained in:
commit
2eafdd53b8
@ -40,8 +40,8 @@
|
||||
<div class='panel-heading'>
|
||||
{% trans "The following items will be created" %}
|
||||
</div>
|
||||
<div class='panel-content'>
|
||||
{% include "hover_image.html" with image=build.part.image hover=True %}
|
||||
<div class='panel-content' style='padding-bottom:16px'>
|
||||
{% include "hover_image.html" with image=build.part.image %}
|
||||
{% if output.serialized %}
|
||||
{{ output.part.full_name }} - {% trans "Serial Number" %} {{ output.serial }}
|
||||
{% else %}
|
||||
|
@ -157,6 +157,17 @@ class BuildOutputCreate(AjaxUpdateView):
|
||||
quantity = form.cleaned_data.get('output_quantity', None)
|
||||
serials = form.cleaned_data.get('serial_numbers', None)
|
||||
|
||||
if quantity:
|
||||
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),
|
||||
)
|
||||
|
||||
# Check that the serial numbers are valid
|
||||
if serials:
|
||||
try:
|
||||
@ -212,7 +223,7 @@ class BuildOutputCreate(AjaxUpdateView):
|
||||
|
||||
# Calculate the required quantity
|
||||
quantity = max(0, build.remaining - build.incomplete_count)
|
||||
initials['output_quantity'] = quantity
|
||||
initials['output_quantity'] = int(quantity)
|
||||
|
||||
return initials
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user