mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Remove unique-together requirement for BomItem model (#3104)
* Remove unique-together requirement for BomItem model Ref: https://github.com/inventree/InvenTree/issues/1254 * Update unit test * Remove unused import
This commit is contained in:
parent
02607bd854
commit
a129c650fe
@ -3,7 +3,6 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db.utils import IntegrityError
|
|
||||||
|
|
||||||
from InvenTree import status_codes as status
|
from InvenTree import status_codes as status
|
||||||
|
|
||||||
@ -194,14 +193,13 @@ class BuildTest(BuildTestBase):
|
|||||||
b.save()
|
b.save()
|
||||||
|
|
||||||
def test_duplicate_bom_line(self):
|
def test_duplicate_bom_line(self):
|
||||||
# Try to add a duplicate BOM item - it should fail!
|
# Try to add a duplicate BOM item - it should be allowed
|
||||||
|
|
||||||
with self.assertRaises(IntegrityError):
|
BomItem.objects.create(
|
||||||
BomItem.objects.create(
|
part=self.assembly,
|
||||||
part=self.assembly,
|
sub_part=self.sub_part_1,
|
||||||
sub_part=self.sub_part_1,
|
quantity=99
|
||||||
quantity=99
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def allocate_stock(self, output, allocations):
|
def allocate_stock(self, output, allocations):
|
||||||
"""
|
"""
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 3.2.13 on 2022-05-31 01:42
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('part', '0076_auto_20220516_0819'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='bomitem',
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
]
|
@ -2899,9 +2899,6 @@ class BomItem(models.Model, DataImportMixin):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("BOM Item")
|
verbose_name = _("BOM Item")
|
||||||
|
|
||||||
# Prevent duplication of parent/child rows
|
|
||||||
unique_together = ('part', 'sub_part')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{n} x {child} to make {parent}".format(
|
return "{n} x {child} to make {parent}".format(
|
||||||
parent=self.part.full_name,
|
parent=self.part.full_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user