mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Fix similar error for Build object
This commit is contained in:
parent
ecfde46838
commit
2760efac18
@ -368,15 +368,21 @@ class BuildItem(models.Model):
|
|||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if self.stock_item is not None and self.stock_item.part is not None:
|
try:
|
||||||
if self.stock_item.part not in self.build.part.required_parts():
|
if self.stock_item.part not in self.build.part.required_parts():
|
||||||
errors['stock_item'] = [_("Selected stock item not found in BOM for part '{p}'".format(p=self.build.part.full_name))]
|
errors['stock_item'] = [_("Selected stock item not found in BOM for part '{p}'".format(p=self.build.part.full_name))]
|
||||||
|
|
||||||
if self.stock_item is not None and self.quantity > self.stock_item.quantity:
|
if self.quantity > self.stock_item.quantity:
|
||||||
errors['quantity'] = [_("Allocated quantity ({n}) must not exceed available quantity ({q})".format(
|
errors['quantity'] = [_("Allocated quantity ({n}) must not exceed available quantity ({q})".format(
|
||||||
n=self.quantity,
|
n=self.quantity,
|
||||||
q=self.stock_item.quantity
|
q=self.stock_item.quantity
|
||||||
))]
|
))]
|
||||||
|
|
||||||
|
except StockItem.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
except Part.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
if len(errors) > 0:
|
if len(errors) > 0:
|
||||||
raise ValidationError(errors)
|
raise ValidationError(errors)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user