mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-11 07:24:15 +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:
@ -529,7 +529,7 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, common.models.MetaMixin, M
|
||||
|
||||
for plugin in registry.with_mixin('validation'):
|
||||
try:
|
||||
plugin.validate_batch_code(self.batch)
|
||||
plugin.validate_batch_code(self.batch, self)
|
||||
except ValidationError as exc:
|
||||
raise ValidationError({
|
||||
'batch': exc.message
|
||||
@ -560,6 +560,7 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, common.models.MetaMixin, M
|
||||
if type(self.batch) is str:
|
||||
self.batch = self.batch.strip()
|
||||
|
||||
# Custom validation of batch code
|
||||
self.validate_batch_code()
|
||||
|
||||
try:
|
||||
|
Reference in New Issue
Block a user