2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-13 08:21:26 +00:00

Limit choices for BomItem Part foreignkey fields

- Only allow 'active' Parts
This commit is contained in:
Oliver Walters
2019-05-05 22:34:00 +10:00
parent 5a9fc399ac
commit b85a4d0895
2 changed files with 32 additions and 2 deletions

View File

@ -464,12 +464,18 @@ class BomItem(models.Model):
# A link to the parent part
# Each part will get a reverse lookup field 'bom_items'
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='bom_items',
limit_choices_to={'buildable': True})
limit_choices_to={
'buildable': True,
'active': True,
})
# A link to the child item (sub-part)
# Each part will get a reverse lookup field 'used_in'
sub_part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='used_in',
limit_choices_to={'consumable': True})
limit_choices_to={
'consumable': True,
'active': True
})
# Quantity required
quantity = models.PositiveIntegerField(default=1, validators=[MinValueValidator(0)])