mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +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'>
|
<div class='panel-heading'>
|
||||||
{% trans "The following items will be created" %}
|
{% trans "The following items will be created" %}
|
||||||
</div>
|
</div>
|
||||||
<div class='panel-content'>
|
<div class='panel-content' style='padding-bottom:16px'>
|
||||||
{% include "hover_image.html" with image=build.part.image hover=True %}
|
{% include "hover_image.html" with image=build.part.image %}
|
||||||
{% if output.serialized %}
|
{% if output.serialized %}
|
||||||
{{ output.part.full_name }} - {% trans "Serial Number" %} {{ output.serial }}
|
{{ output.part.full_name }} - {% trans "Serial Number" %} {{ output.serial }}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -157,6 +157,17 @@ class BuildOutputCreate(AjaxUpdateView):
|
|||||||
quantity = form.cleaned_data.get('output_quantity', None)
|
quantity = form.cleaned_data.get('output_quantity', None)
|
||||||
serials = form.cleaned_data.get('serial_numbers', 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
|
# Check that the serial numbers are valid
|
||||||
if serials:
|
if serials:
|
||||||
try:
|
try:
|
||||||
@ -212,7 +223,7 @@ class BuildOutputCreate(AjaxUpdateView):
|
|||||||
|
|
||||||
# Calculate the required quantity
|
# Calculate the required quantity
|
||||||
quantity = max(0, build.remaining - build.incomplete_count)
|
quantity = max(0, build.remaining - build.incomplete_count)
|
||||||
initials['output_quantity'] = quantity
|
initials['output_quantity'] = int(quantity)
|
||||||
|
|
||||||
return initials
|
return initials
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user