mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 13:56:30 +00:00
Extend functionality of custom validation plugins (#4391)
* Pass "Part" instance to plugins when calling validate_serial_number * Pass part instance through when validating IPN * Improve custom part name validation - Pass the Part instance through to the plugins - Validation is performed at the model instance level - Updates to sample plugin code * Pass StockItem through when validating batch code * Pass Part instance through when calling validate_serial_number * Bug fix * Update unit tests * Unit test fixes * Fixes for unit tests * More unit test fixes * More unit tests * Furrther unit test fixes * Simplify custom batch code validation * Further improvements to unit tests * Further unit test
This commit is contained in:
.gitignore
InvenTree
@ -130,7 +130,7 @@ class PartCategoryAPITest(InvenTreeAPITestCase):
|
||||
for jj in range(10):
|
||||
Part.objects.create(
|
||||
name=f"Part xyz {jj}_{ii}",
|
||||
description="A test part",
|
||||
description="A test part with a description",
|
||||
category=child
|
||||
)
|
||||
|
||||
@ -428,8 +428,8 @@ class PartCategoryAPITest(InvenTreeAPITestCase):
|
||||
# Make sure that we get an error if we try to create part in the structural category
|
||||
with self.assertRaises(ValidationError):
|
||||
part = Part.objects.create(
|
||||
name="Part which shall not be created",
|
||||
description="-",
|
||||
name="-",
|
||||
description="Part which shall not be created",
|
||||
category=structural_category
|
||||
)
|
||||
|
||||
@ -446,8 +446,8 @@ class PartCategoryAPITest(InvenTreeAPITestCase):
|
||||
|
||||
# Create the test part assigned to a non-structural category
|
||||
part = Part.objects.create(
|
||||
name="Part which category will be changed to structural",
|
||||
description="-",
|
||||
name="-",
|
||||
description="Part which category will be changed to structural",
|
||||
category=non_structural_category
|
||||
)
|
||||
|
||||
@ -743,7 +743,7 @@ class PartAPITest(PartAPITestBase):
|
||||
|
||||
# First, construct a set of template / variant parts
|
||||
master_part = Part.objects.create(
|
||||
name='Master', description='Master part',
|
||||
name='Master', description='Master part which has some variants',
|
||||
category=category,
|
||||
is_template=True,
|
||||
)
|
||||
@ -1323,7 +1323,7 @@ class PartCreationTests(PartAPITestBase):
|
||||
url = reverse('api-part-list')
|
||||
|
||||
name = "Kaltgerätestecker"
|
||||
description = "Gerät"
|
||||
description = "Gerät Kaltgerätestecker strange chars should get through"
|
||||
|
||||
data = {
|
||||
"name": name,
|
||||
@ -1347,7 +1347,7 @@ class PartCreationTests(PartAPITestBase):
|
||||
reverse('api-part-list'),
|
||||
{
|
||||
'name': f'thing_{bom}{img}{params}',
|
||||
'description': 'Some description',
|
||||
'description': 'Some long description text for this part',
|
||||
'category': 1,
|
||||
'duplicate': {
|
||||
'part': 100,
|
||||
@ -2474,7 +2474,7 @@ class BomItemTest(InvenTreeAPITestCase):
|
||||
# Create a variant part!
|
||||
variant = Part.objects.create(
|
||||
name=f"Variant_{ii}",
|
||||
description="A variant part",
|
||||
description="A variant part, with a description",
|
||||
component=True,
|
||||
variant_of=sub_part
|
||||
)
|
||||
@ -2672,7 +2672,7 @@ class BomItemTest(InvenTreeAPITestCase):
|
||||
# Create a variant part
|
||||
vp = Part.objects.create(
|
||||
name=f"Var {i}",
|
||||
description="Variant part",
|
||||
description="Variant part description field",
|
||||
variant_of=bom_item.sub_part,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user