InvenTree/InvenTree/stock
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
..
fixtures [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
migrations Adds 'consumable' field to BomItem model (#2890) 2022-09-24 23:45:56 +10:00
templates/stock Barcode Refactor (#3640) 2022-09-15 14:14:51 +10:00
__init__.py Docstring checks in QC checks (#3089) 2022-06-02 01:37:39 +10:00
admin.py Merge pull request from GHSA-7rq4-qcpw-74gq 2022-06-15 18:32:35 +10:00
api.py [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
apps.py Docstring checks in QC checks (#3089) 2022-06-02 01:37:39 +10:00
filters.py Tree query improvements (#3443) 2022-08-01 13:43:27 +10:00
models.py [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
serializers.py [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
test_api.py [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
test_migrations.py Int migration fix (#3323) 2022-07-15 11:57:27 +10:00
test_views.py Null units fix (#3663) 2022-09-08 15:18:43 +10:00
tests.py [Plugin] Allow custom plugins for running validation routines (#3776) 2022-10-18 23:50:07 +11:00
urls.py Migrate "Convert to Variant" form to the API (#3183) 2022-06-12 16:06:11 +10:00
views.py Migrate "Convert to Variant" form to the API (#3183) 2022-06-12 16:06:11 +10:00