From 4eb8c60ee02338c7bbf95c956093f41f7d1de734 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 12 Oct 2021 22:22:49 +1100 Subject: [PATCH] Add new BomItemSubstitute model --- InvenTree/part/models.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 8c43a623a0..f883250811 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2613,6 +2613,36 @@ class BomItem(models.Model): return "{pmin} to {pmax}".format(pmin=pmin, pmax=pmax) +class BomItemSubstitute(models.Model): + """ + A BomItemSubstitute provides a specification for alternative parts, + which can be used in a bill of materials. + + Attributes: + bom_item: Link to the parent BomItem instance + part: The part which can be used as a substitute + """ + + bom_item = models.ForeignKey( + BomItem, + on_delete=models.CASCADE, + related_name='substitutes', + verbose_name=_('BOM Item'), + help_text=_('Parent BOM item'), + ) + + part = models.ForeignKey( + Part, + on_delete=models.CASCADE, + related_name='substitute_items', + verbose_name=_('Part'), + help_text=_('Substitute part'), + limit_choices_to={ + 'component': True, + } + ) + + class PartRelated(models.Model): """ Store and handle related parts (eg. mating connector, crimps, etc.) """