2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 19:50:59 +00:00

[Plugin] Allow custom plugins for running validation routines (#3776)

* Adds new plugin mixin for performing custom validation steps

* Adds simple test plugin for custom validation

* Run part name and IPN validators checks through loaded plugins

* Expose more validation functions to plugins:

- SalesOrder reference
- PurchaseOrder reference
- BuildOrder reference

* Remove custom validation of reference fields

- For now, this is too complex to consider given the current incrementing-reference implementation
- Might revisit this at a later stage.

* Custom validation of serial numbers:

- Replace "checkIfSerialNumberExists" method with "validate_serial_number"
- Pass serial number through to custom plugins
- General code / docstring improvements

* Update unit tests

* Update InvenTree/stock/tests.py

Co-authored-by: Matthias Mair <code@mjmair.com>

* Adds global setting to specify whether serial numbers must be unique globally

- Default is false to preserve behaviour

* Improved error message when attempting to create stock item with invalid serial numbers

* Add more detail to existing serial error message

* Add unit testing for serial number uniqueness

* Allow plugins to convert a serial number to an integer (for optimized sorting)

* Add placeholder plugin methods for incrementing and decrementing serial numbers

* Typo fix

* Add improved method for determining the "latest" serial number

* Remove calls to getLatestSerialNumber

* Update validate_serial_number method

- Add option to disable checking for duplicates
- Don't pass optional StockItem through to plugins

* Refactor serial number extraction methods

- Expose the "incrementing" portion to external plugins

* Bug fixes

* Update unit tests

* Fix for get_latest_serial_number

* Ensure custom serial integer values are clipped

* Adds a plugin for validating and generating hexadecimal serial numbers

* Update unit tests

* Add stub methods for batch code functionality

* remove "hex serials" plugin

- Was simply breaking unit tests

* Allow custom plugins to generate and validate batch codes

- Perform batch code validation when StockItem is saved
- Improve display of error message in modal forms

* Fix unit tests for stock app

* Log message if plugin has a duplicate slug

* Unit test fix

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
Oliver
2022-10-18 23:50:07 +11:00
committed by GitHub
parent 269b269de3
commit 906ae218aa
24 changed files with 755 additions and 289 deletions

View File

@ -96,6 +96,7 @@
location: 7
quantity: 1
serial: 1000
serial_int: 1000
level: 0
tree_id: 0
lft: 0
@ -121,6 +122,7 @@
location: 7
quantity: 1
serial: 1
serial_int: 1
level: 0
tree_id: 0
lft: 0
@ -133,6 +135,7 @@
location: 7
quantity: 1
serial: 2
serial_int: 2
level: 0
tree_id: 0
lft: 0
@ -145,6 +148,7 @@
location: 7
quantity: 1
serial: 3
serial_int: 3
level: 0
tree_id: 0
lft: 0
@ -157,6 +161,7 @@
location: 7
quantity: 1
serial: 4
serial_int: 4
level: 0
tree_id: 0
lft: 0
@ -169,6 +174,7 @@
location: 7
quantity: 1
serial: 5
serial_int: 5
level: 0
tree_id: 0
lft: 0
@ -181,6 +187,7 @@
location: 7
quantity: 1
serial: 10
serial_int: 10
level: 0
tree_id: 0
lft: 0
@ -193,6 +200,7 @@
location: 7
quantity: 1
serial: 11
serial_int: 11
level: 0
tree_id: 0
lft: 0
@ -205,6 +213,7 @@
location: 7
quantity: 1
serial: 12
serial_int: 12
level: 0
tree_id: 0
lft: 0
@ -217,6 +226,7 @@
location: 7
quantity: 1
serial: 20
serial_int: 20
level: 0
tree_id: 0
lft: 0
@ -231,6 +241,7 @@
location: 7
quantity: 1
serial: 21
serial_int: 21
level: 0
tree_id: 0
lft: 0
@ -245,6 +256,7 @@
location: 7
quantity: 1
serial: 22
serial_int: 22
level: 0
tree_id: 0
lft: 0