InvenTree/InvenTree/plugin
Oliver 906ae218aa
[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>
2022-10-18 23:50:07 +11:00
..
base [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
builtin Check user permissions before linking or un-linking barcodes (#3772) 2022-10-13 12:14:36 +11:00
migrations user notification settings 2022-04-04 23:46:19 +02:00
mixins [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
mock Improve plugin testing (#3517) 2022-08-16 13:09:48 +10:00
samples [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
templatetags Add more checks to pre-commit (#3132) 2022-06-06 08:56:52 +10:00
__init__.py BREAKING (#3283) 2022-07-03 12:32:35 +10:00
admin.py Plugin framework updates (#3535) 2022-08-16 16:10:18 +10:00
api.py Plugin API refactor (#3637) 2022-10-17 22:08:28 +11:00
apps.py Allow auto-loading of plugins in certain conditions (#3762) 2022-10-09 09:07:51 +11:00
events.py Docstring checks in QC checks (#3089) 2022-06-02 01:37:39 +10:00
helpers.py Plugin load fix (#3768) 2022-10-11 23:15:24 +11:00
models.py out-of-scope:update settings value lookup to include typ (#3636) 2022-09-02 16:51:16 +10:00
plugin.py Plugin load fix (#3768) 2022-10-11 23:15:24 +11:00
registry.py [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
serializers.py Switch to pathlib (#3392) 2022-07-27 10:42:34 +10:00
template.py Plugin framework updates (#3535) 2022-08-16 16:10:18 +10:00
test_api.py Reduce duplication in plugin testing (#3800) 2022-10-17 20:29:54 +11:00
test_helpers.py Optimisations for editable installs of plugins (#3634) 2022-09-05 13:03:26 +10:00
test_plugin.py Fix: Broken subfolder tests in postgres/docker CI in master (#3559) 2022-08-17 09:10:56 +10:00
urls.py Docstring checks in QC checks (#3089) 2022-06-02 01:37:39 +10:00
views.py Ensure an error gets logged when a delivery method fails (#3144) 2022-06-07 08:58:00 +10:00