2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

Prevent div-by-zero error (#4967) (#4968)

- Div-by-zero could occur when calculating how many items can be built for a part
- Might result if (somehow) the BomItem has a quantity of zero

(cherry picked from commit d8965c6c2ba68a657b6cd489bd265bd63530f403)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2023-06-05 13:49:39 +10:00 committed by GitHub
parent 5b6d999091
commit 1c4362c42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1293,6 +1293,11 @@ class Part(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
)
for item in queryset.all():
if item.quantity <= 0:
# Ignore zero-quantity items
continue
# Iterate through each item in the queryset, work out the limiting quantity
quantity = item.available_stock + item.substitute_stock