mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Prevent build outputs being created with zero quantity
This commit is contained in:
parent
a41eca1cb3
commit
b387b4e173
@ -95,17 +95,24 @@ 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:
|
if quantity is not None:
|
||||||
build = self.get_object()
|
build = self.get_object()
|
||||||
|
|
||||||
# Check that requested output don't exceed build remaining quantity
|
# Check that requested output don't exceed build remaining quantity
|
||||||
maximum_output = int(build.remaining - build.incomplete_count)
|
maximum_output = int(build.remaining - build.incomplete_count)
|
||||||
|
|
||||||
if quantity > maximum_output:
|
if quantity > maximum_output:
|
||||||
form.add_error(
|
form.add_error(
|
||||||
'output_quantity',
|
'output_quantity',
|
||||||
_('Maximum output quantity is ') + str(maximum_output),
|
_('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
|
# Check that the serial numbers are valid
|
||||||
if serials:
|
if serials:
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user