2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 19:50:59 +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:
Oliver
2023-03-07 22:43:12 +11:00
committed by GitHub
parent edae82caa5
commit abeb85cbb3
22 changed files with 193 additions and 137 deletions

View File

@ -161,7 +161,7 @@ class StockLocationTest(StockAPITestCase):
# Create stock items in the location to be deleted
for jj in range(3):
stock_items.append(StockItem.objects.create(
batch=f"Stock Item xyz {jj}",
batch=f"Batch xyz {jj}",
location=stock_location_to_delete,
part=part
))
@ -180,7 +180,7 @@ class StockLocationTest(StockAPITestCase):
# Create stock items in the sub locations
for jj in range(3):
child_stock_locations_items.append(StockItem.objects.create(
batch=f"Stock item in sub location xyz {jj}",
batch=f"B xyz {jj}",
part=part,
location=child
))
@ -272,7 +272,7 @@ class StockLocationTest(StockAPITestCase):
# Create the test stock item located to a non-structural category
item = StockItem.objects.create(
batch="Item which will be tried to relocated to a structural location",
batch="BBB",
location=non_structural_location,
part=part
)
@ -951,7 +951,7 @@ class StockItemTest(StockAPITestCase):
# First, construct a set of template / variant parts
master_part = part.models.Part.objects.create(
name='Master', description='Master part',
name='Master', description='Master part which has variants',
category=category,
is_template=True,
)