diff --git a/InvenTree/part/migrations/0066_bomitem_allow_variants.py b/InvenTree/part/migrations/0066_bomitem_allow_variants.py new file mode 100644 index 0000000000..e545c8e3cb --- /dev/null +++ b/InvenTree/part/migrations/0066_bomitem_allow_variants.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2 on 2021-06-01 03:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0065_auto_20210505_2144'), + ] + + operations = [ + migrations.AddField( + model_name='bomitem', + name='allow_variants', + field=models.BooleanField(default=False, help_text='Stock items for variant parts can be used for this BOM item', verbose_name='Allow Variants'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 7db998ab3d..7b9038fecb 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2240,6 +2240,7 @@ class BomItem(models.Model): note: Note field for this BOM item checksum: Validation checksum for the particular BOM line item inherited: This BomItem can be inherited by the BOMs of variant parts + allow_variants: Stock for part variants can be substituted for this BomItem """ def save(self, *args, **kwargs): @@ -2288,6 +2289,12 @@ class BomItem(models.Model): help_text=_('This BOM item is inherited by BOMs for variant parts'), ) + allow_variants = models.BooleanField( + default=False, + verbose_name=_('Allow Variants'), + help_text=_('Stock items for variant parts can be used for this BOM item') + ) + def get_item_hash(self): """ Calculate the checksum hash of this BOM line item: diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 04e0b7a119..d03a37c6dc 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -453,6 +453,7 @@ class BomItemSerializer(InvenTreeModelSerializer): class Meta: model = BomItem fields = [ + 'allow_variants', 'inherited', 'note', 'optional', @@ -460,16 +461,16 @@ class BomItemSerializer(InvenTreeModelSerializer): 'pk', 'part', 'part_detail', + 'purchase_price_avg', + 'purchase_price_max', + 'purchase_price_min', + 'purchase_price_range', 'quantity', 'reference', 'sub_part', 'sub_part_detail', # 'price_range', 'validated', - 'purchase_price_min', - 'purchase_price_max', - 'purchase_price_avg', - 'purchase_price_range', ]