* Create new model for storing Part pricing data
Currently this model does not "do" anything but will be used for caching pre-calculated pricing information
* Define function for accessing pricing information for a specific part
* Adds admin site support for new PartPricing model
* Specify role for PartPricing model
* Allow blank values for PartPricing model fields
* Add some TODO entries
* Update migration files to sync with latest master
* Expose API endpoint for viewing part pricing information
* Update migration file
* Improvements:
- Updated model with new fields
- Code for calculating BOM price
- Code for calculating internal price
- Code for calculating supplier price
- Updated unit testing
* Fix (and test) for API serializer
* Including min/max pricing data in part serializer
* Bump API version
* Add pricing overview information in part table
- Adds helper function for formatting currency data
- No longer pre-render "price strings" on the server
* Overhaul of BOM API
- Pricing data no longer calculated "on the fly"
- Remove expensive annotation operations
- Display cached price range information in BOM table
* Filter BOM items by "has pricing"
* Part API endpoint can be filtered by price range
* Updpated API version notes
* Improvements for price caching calculations
- Handle null price values
- Handle case where conversion rates are missing
- Allow manual update via API
* Button to manually refresh pricing
* Improve rendering of price-break table
* Update supplier part pricing table
* Updated js functions
* Adds background task to update assembly pricing whenever a part price cache is changed
* Updates for task offloading
* HTML tweaks
* Implement calculation of historical purchase cost
- take supplier part pack size into account
- improve unit tests
* Improvements for pricing tab rendering
* Refactor of pricing page
- Move javascript functions out into separate files
- Change price-break tables to use bar graphs
- Display part pricing history table and chart
- Remove server-side rendering for price history data
- Fix rendering of supplier pricing table
- Adds extra filtering options to the SupplierPriceBreak API endpoint
* Refactor BOM pricing chart / table
- Display as bar chart with min/max pricing
- Display simplified BOM table
* Update page anchors
* Improvements for BOM pricing table display
* Refactoring sales data tables
- Add extra data and filter options to sales order API endpoints
- Display sales order history table and chart
* Add extra fields to PartPricing model:
- sale_price_min
- sale_price_max
- sale_history_min
- sale_history_max
* Calculate and cache sale price data
* Update part pricing when PurchaseOrder is completed
* Update part pricing when sales order is completed
* Signals for updating part pricing cache
- Whenever an internal price break is created / edited / deleted
- Whenever a sale price break is created / edited / deleted
* Also trigger part pricing update when BomItem is created / edited / deleted
* Update part pricing whenever a supplier price break is updated
* Remove has_complete_bom_pricing method
* Export min/max pricing data in BOM file
* Fix pricing data in BOM export
- Calculate total line cost
- Use more than two digits
* Add pricing information to part export
Also some improvements to part exporting
* Allow download of part category table
* Allow export of stock location data to file
* Improved exporting of StockItem data
* Add cached variant pricing data
- New fields in part pricing model
- Display variant pricing overview in "pricing" tab
* Remove outdated "PART_SHOW_PRICE_HISTORY" setting
* Adds scheduled background task to periodically update part pricing
* Internal prices can optionally override other pricing
* Update js file checks
* Update price breaks to use 6 decimal places
* Fix for InvenTreeMoneySerializer class
- Allow 6 decimal places through the API
* Update for supplier price break table
* javascript linting fix
* Further js fixes
* Unit test updates
* Improve rendering of currency in templates
- Do not artificially limit to 2 decimal places
* Unit test fixes
* Add pricing information to part "details" tab
* Tweak for money formatting
* Enable sort-by-price in BOM table
* More unit test tweaks
* Update BOM exporting
* Fixes for background worker process
- To determine if worker is running, look for *any* successful task, not just heartbeat
- Heartbeat rate increased to 5 minute intervals
- Small adjustments to django_q settings
Ref: https://github.com/inventree/InvenTree/issues/3921
(cherry picked from commit cb26003b92)
* Force background processing of heartbeat task when server is started
- Removes the ~5 minute window in which the server "thinks" that the worker is not actually running
* Adjust strategy for preventing recursion
- Rather than looking for duplicate parts, simply increment a counter
- Add a "scheduled_for_update" flag to prevent multiple updates being scheduled
- Consolidate migration files
* Adds helper function for rendering a range of prices
* Include variant cost in calculations
* Fixes for "has_pricing" API filters
* Ensure part pricing status flags are reset when the server restarts
* Bug fix for BOM API filter
* Include BOM quantity in BOM pricing chart
* Small tweaks to pricing tab
* Prevent caching when looking up settings in background worker
- Caching across mnultiple processes causes issues
- Need to move to something like redis to solve this
- Ref: https://github.com/inventree/InvenTree/issues/3921
* Fixes for /part/pricing/ detail API endpoint
* Update pricing tab
- Consistent naming
* Unit test fixes
* Prevent pricing updates when loading test fixtures
* Fix for Part.pricing
* Updates for "check_missing_pricing"
* Change to pie chart for BOM pricing
* Unit test fix
* Updates
- Sort BOM pie chart correctly
- Simplify PartPricing.is_valid
- Pass "limit" through to check_missing_pricing
- Improved logic for update scheduling
* Add option for changing how many decimals to use when displaying pricing data
* remove old unused setting
* Consolidate settings tabs for pricing and currencies
* Fix CI after changing settings page
* Fix rendering for "Supplier Pricing"
- Take unit pricing / pack size into account
* Extra filtering / ordering options for the SupplierPriceBreak API endpoint
* Fix for purchase price history graph
- Use unit pricing (take pack size into account)
* JS fixes
* Remove client-side length validation in form inputs
- Let the server throw an error (so the user sees it)
* Update instances of models.URLField to InvenTreeURLField
* Add extra setting to guard whether purchase order items can be edited "after the fact"
* Improvements for "extra" purchase order line table
* Similar changes for sales order table
* Improvements for image download helper
(cherry picked from commit 43b0d3ca55)
* Allow editing of extra line items in order table
* Allow addition of extra line items even if order is not "pending"
* Allow addition and editing of extra line items for sales orders
* javascript linting
* Coerce setting value to a boolean
* Ignore inactive users when sending notification emails
* Only send UI notifications to active users
* Fixes for unit tests
* 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>
* fix schedule registration
* add collection step for tasks
* make tasks register configurable
* extend docs
* Also run InvenTree setup in testing
* fix import loading method
* fix wrong task registration
* do not test
* do only distinct testing
* ignore import error for coverage
* define a simple model mixin class for barcode
* Adds generic function for assigning a barcode to a model instance
* StockItem model now implements the BarcodeMixin class
* Implement simple unit tests for new code
* Fix unit tests
* Data migration for uid field
* Remove references to old 'uid' field
* Migration for removing old uid field from StockItem model
* Bump API version
* Change lookup_barcode to be a classmethod
* Change barcode_model_type to be a class method
* Cleanup for generic barcode scan and assign API:
- Raise ValidationError as appropriate
- Improved unit testing
- Groundwork for future generic implementation
* Further unit tests for barcode scanning
* Adjust error messages for compatibility
* Unit test fix
* Fix hash_barcode function
- Add unit tests to ensure it produces the same results as before the refactor
* Add BarcodeMixin to Part model
* Remove old format_barcode function from Part model
* Further fixes for unit tests
* Add support for assigning arbitrary barcode to Part instance
- Simplify barcode API
- Add more unit tests
* More unit test fixes
* Update unit test
* Adds generic endpoint for unassigning barcode data
* Update web dialog for unlinking a barcode
* Template cleanup
* Add Barcode mixin to StockLocation class
* Add some simple unit tests for new model mixin
* Support assigning / unassigning barcodes for StockLocation
* remove failing outdated test
* Update template to integrate new barcode support for StockLocation
* Add BarcodeMixin to SupplierPart model
* Adds QR code view for SupplierPart
* Major simplification of barcode API endpoints
- Separate existing barcode plugin into two separate classes
- Simplify and consolidate the response from barcode scanning
- Update unit testing
* Yet more unit test fixes
* Yet yet more unit test fixes
* Adds 'pack_size' field to SupplierPart model
* Edit pack_size for SupplierPart via API
* Display pack size in supplier part page template
* Improve table ordering for SupplierPart table
* Fix for API filtering
- Need to use custom filter class
* Adds functionality to duplicate an existing SupplierPart
* Bump API version number
* Display annotation of pack size in purchase order line item table
* Display additional information in part purchase order table
* Add UOM to purchase order table
* Improve receive items functionality
* Indicate quantity which will be received in modal form
* Update the received quantity as the user changes the value
* Take the pack_size into account when receiving line items
* Take supplierpart pack size into account when receiving line items
* Add "pack size" column to purchase order line item table
* Tweak supplier part table
* Update 'on_order' queryset annotation to take pack_size into account
- May god have mercy on my soul
* Adds a unit test to validate that the on_order queryset annotation is working as expected
* Update Part.on_order method to take pack_size into account
- Check in existing unit test also
* Fix existing unit tests
- Previous unit test was actually in error
- Logic for calculating "on_order" was broked
* More unit tests for receiving items against a purchase order
* Allow pack_size < 1
* Display pack size when adding / editing PurchaseOrderLineItem
* Fix bug in part purchase order table
* Update part purchase order table again
* Exclude notificationmessage when exporting dataset
* Also display pack size when ordering parts from secondary form
* javascript linting
* Change user facing strings to "Pack Quantity"
* Add confirmation field for incomplete purchase orders
* Add similar functionality for SalesOrder
- Complete form is now context sensitive
- Allow user to specify if order should be closed with incomplete lines
* Update API version
* JS linting
* Updated unit tests
* Adds option for duplicating an existing purchase order
- Copy line items across
* Update API version
* JS linting
* Adds option for duplication of extra lines
* Decimal point rounding fix
* Unit tests for PO duplication via the API
* Move JS code from html to external .js file
* Add secondary dialog for creating a new SupplierPart from the PurchaseOrderLineItem dialog
* JS linting
* Add fix for stock migration
- Ensure the serial number is not too large when performing migration
- Add unit test for data migration
(cherry picked from commit 661fbf0e3d)
* Add similar fixes for PO and SO migrations
(cherry picked from commit bde23c130c)
* And similar fix for BuildOrder reference field
(cherry picked from commit ca0f4e0031)
* Update unit tests for API plugin mixin class
- API at previous target URL has changed
- Simplier to use the github API as a test case
(cherry picked from commit dfe3172b7d)
* Revert test database name
(cherry picked from commit 53333c29c3)
* Override default URL behaviour for unit test
(cherry picked from commit 2c12a69529)
* Adds a configurable 'reference pattern' to the IndexingReferenceMixin class
* Expand tests for reference_pattern validator:
- Prevent inclusion of illegal characters
- Prevent multiple groups of hash (#) characters
- Add unit tests
* Validator now checks for valid strftime formatter
* Adds build order reference pattern
* Adds function for creating a valid regex from the supplied pattern
- More unit tests
- Use it to validate BuildOrder reference field
* Refactoring the whole thing again - try using python string.format
* remove datetime-matcher from requirements.txt
* Add some more formatting helper functions
- Construct a regular expression from a format string
- Extract named values from a string, based on a format string
* Fix validator for build order reference field
* Adding unit tests for the new format string functionality
* Adds validation for reference fields
* Require the 'ref' format key as part of a valid reference pattern
* Extend format extraction to allow specification of integer groups
* Remove unused import
* Fix requirements
* Add method for generating the 'next' reference field for a model
* Fix function for generating next BuildOrder reference value
- A function is required as class methods cannot be used
- Simply wraps the existing class method
* Remove BUILDORDER_REFERENCE_REGEX setting
* Add unit test for build order reference field validation
* Adds unit testing for extracting integer values from a reference field
* Fix bugs from previous commit
* Add unit test for generation of default build order reference
* Add data migration for BuildOrder model
- Update reference field with old prefix
- Construct new pattern based on old prefix
* Adds unit test for data migration
- Check that the BuildOrder reference field is updated as expected
* Remove 'BUILDORDER_REFERENCE_PREFIX' setting
* Adds new setting for SalesOrder reference pattern
* Update method by which next reference value is generated
* Improved error handling in api_tester code
* Improve automated generation of order reference fields
- Handle potential errors
- Return previous reference if something goes wrong
* SalesOrder reference has now been updated also
- New reference pattern setting
- Updated default and validator for reference field
- Updated serializer and API
- Added unit tests
* Migrate the "PurchaseOrder" reference field to the new system
* Data migration for SalesOrder and PurchaseOrder reference fields
* Remove PURCHASEORDER_REFERENCE_PREFIX
* Remove references to SALESORDER_REFERENCE_PREFIX
* Re-add maximum value validation
* Bug fixes
* Improve algorithm for generating new reference
- Handle case where most recent reference does not conform to the reference pattern
* Fixes for 'order' unit tests
* Unit test fixes for order app
* More unit test fixes
* More unit test fixing
* Revert behaviour for "extract_int" clipping function
* Unit test value fix
* Prevent build order notification if we are importing records
* Remove stat context variables
* Revert "Remove stat context variables"
This reverts commit 0989c308d0.
* remove old backport
* move requirements
* move isort
* move migrations-tests
* add pip-tools as req and add hook
* Use hashes and also run when txt files are added
* Update to hashes in requirements
* update requirements install path
* remove allauth-2fa for a test
* install dev-requirements
* re-enable allauth
* remove hashes from pre normal setup
* Remove version bindings if they are the laest
* move depencies to upper bound
* fix django-money
* remove windows specific requirements
* also install dependencies
* update markdownify
* remove django-admin-shell
* remove unneeded packages
* add docs
* remove pins and fix pre-commit pipeline
* pin django-money
* really remove admin shell
* return default behaviour for money serializer
* pip fix
* update filter name
* set decimal for output
* add migrations
* pin coveralls
* update requirements
Co-authored-by: Oliver Walters <oliver.henry.walters@gmail.com>
* Add 'virtual': False requirement to sales order items
* Adds "virtual" filter for part table
* Adds extra validation to the SalesOrderLineItem model
* Prevent creation of stock items for virtual parts
- Add validation check to clean() method of StockItem model
- Improve validation message for StockItemSerializer class
* Hide "new stock item" button for virtual parts
* Hide more buttons for 'virtual' parts
* Remove reliance on django-markdownx
- We are now rendering notes on the client side using easymde
- No longer any need to utilize the markdownx integration
- Adds character limit for notes fields`
* Adjust legacy migrations - remove references to markdownx
* Fix bug for company notes field
* use shims for API view inheritation
* Add mixin for input sanitation
* fix clean operation to fix all string values
* Also clean up dicts
this is to future-proof this function
* Update docstirng
* proof custom methods against XSS through authenticated users
* Create custom ModelResource subclass
- Strips illegal starting characters from string cells
- Prevents formula injection
* Update all existing ModelResource classes to base off InvenTreeResource
* Handle more complex case where an illegal char is hidden behind another one
* Ensure an error gets logged when a delivery method fails
- Refactor existing code to log a custom error to the database
- Limit error notifications to UI
* Adjust unit test
* Clear existing notifications before run
* Add some debug to work out what is going on
* Accommodate extra notification
* Trigger a notification when a new SalesOrder is created
- Notify the "responsible" owners (excluding the creator)
- Add unit test for new notification
* Adds notification when a new PurchaseOrder is created
* Add notification when a new build order is created
- Includes unit tests
* Refactor order notification code
- Adds a "exclude users" option for sending notifications
* Fixes for notification refactoring
* make notification a helper
* reduce statements togehter
* make reuse easier
* Add docs
* Make context variables clearer
* fix assertation
* Fix set notation
Co-authored-by: Matthias <code@mjmair.com>
* Introduces a BulkDelete API mixin class
- Allows deletion of multiple items against a single API request
* Bump API version
* Adds BulkDelete mixin to StockItemTestResult API class
* refactor "multi BOM Item delete" to use new approach
* Refactor various attachment API endpoints
* Refactor multi delete for StockItem
* Convert remaining enndpoints over
* Fix for API test code
* Adds a background task to notify users when a PurchaseOrder becomes overdue
* Schedule the overdue purchaseorder check to occur daily
* Allow notifications to be sent to "Owner" instances
- Extract user information from the Owner instance
* add unit test to ensure notifications are sent for overdue purchase orders
* Adds notification for overdue sales orders
* Clean up notification display panel
- Simplify rendering
- Order "newest at top"
- Element alignment tweaks
* style fixes
* More style fixes
* Tweak notification padding
* Fix import order
* Adds task to notify user of overdue build orders
* Adds unit tests for build order notifications
* Refactor subject line for emails:
- Use the configured instance title as a prefix for the subject line
* Add email template for overdue build orders
* Fix unit tests to accommodate new default value
* Logic error fix
* Add new global setting to control auto-upload of test reports
* Adds callback to attach a copy of the test report when printing
* Fix for all attachment API endpoints
- The AttachmentMixin must come first!
- User was not being set, as the custom 'perform_create' function was never called
* Remove duplicated UserSerializer
* display uploading user in attachment table
* Add unit test to check the test report is automatically uploaded
* Refactor out 'ordering' serializer annotation field
* Refactor BomItem serializer annotations
* Factor out MPTT OuterRef query
* Add 'available_stock' annotation to SalesOrderLineItem serializer
- Allows for better rendering of stock availability in sales order table
* Improve 'available quantity' rendering of salesorderlineitem table
* Bump API version
* Add docstring
* Add pre-commit to the stack
* exclude static
* Add locales to excludes
* fix style errors
* rename pipeline steps
* also wait on precommit
* make template matching simpler
* Use the same code for python setup everywhere
* use step and cache for python setup
* move regular settings up into general envs
* just use full update
* Use invoke instead of static references
* make setup actions more similar
* use python3
* refactor names to be similar
* fix runner version
* fix references
* remove incidential change
* use matrix for os
* Github can't do this right now
* ignore docstyle errors
* Add seperate docstring test
* update flake call
* do not fail on docstring
* refactor setup into workflow
* update reference
* switch to action
* resturcture
* add bash statements
* remove os from cache
* update input checks
* make code cleaner
* fix boolean
* no relative paths
* install wheel by python
* switch to install
* revert back to simple wheel
* refactor import export tests
* move setup keys back to not disturbe tests
* remove docstyle till that is fixed
* update references
* continue on error
* add docstring test
* use relativ action references
* Change step / job docstrings
* update to merge
* reformat comments 1
* fix docstrings 2
* fix docstrings 3
* fix docstrings 4
* fix docstrings 5
* fix docstrings 6
* fix docstrings 7
* fix docstrings 8
* fix docstirns 9
* fix docstrings 10
* docstring adjustments
* update the remaining docstrings
* small docstring changes
* fix function name
* update support files for docstrings
* Add missing args to docstrings
* Remove outdated function
* Add docstrings for the 'build' app
* Make API code cleaner
* add more docstrings for plugin app
* Remove dead code for plugin settings
No idea what that was even intended for
* ignore __init__ files for docstrings
* More docstrings
* Update docstrings for the 'part' directory
* Fixes for related_part functionality
* Fix removed stuff from merge 99676ee
* make more consistent
* Show statistics for docstrings
* add more docstrings
* move specific register statements to make them clearer to understant
* More docstrings for common
* and more docstrings
* and more
* simpler call
* docstrings for notifications
* docstrings for common/tests
* Add docs for common/models
* Revert "move specific register statements to make them clearer to understant"
This reverts commit ca96654622.
* use typing here
* Revert "Make API code cleaner"
This reverts commit 24fb68bd3e.
* docstring updates for the 'users' app
* Add generic Meta info to simple Meta classes
* remove unneeded unique_together statements
* More simple metas
* Remove unnecessary format specifier
* Remove extra json format specifiers
* Add docstrings for the 'plugin' app
* Docstrings for the 'label' app
* Add missing docstrings for the 'report' app
* Fix build test regression
* Fix top-level files
* docstrings for InvenTree/InvenTree
* reduce unneeded code
* add docstrings
* and more docstrings
* more docstrings
* more docstrings for stock
* more docstrings
* docstrings for order/views
* Docstrings for various files in the 'order' app
* Docstrings for order/test_api.py
* Docstrings for order/serializers.py
* Docstrings for order/admin.py
* More docstrings for the order app
* Add docstrings for the 'company' app
* Add unit tests for rebuilding the reference fields
* Prune out some more dead code
* remove more dead code
Co-authored-by: Oliver Walters <oliver.henry.walters@gmail.com>
* Add pre-commit to the stack
* exclude static
* Add locales to excludes
* fix style errors
* rename pipeline steps
* also wait on precommit
* make template matching simpler
* Use the same code for python setup everywhere
* use step and cache for python setup
* move regular settings up into general envs
* just use full update
* Use invoke instead of static references
* make setup actions more similar
* use python3
* refactor names to be similar
* fix runner version
* fix references
* remove incidential change
* use matrix for os
* Github can't do this right now
* ignore docstyle errors
* Add seperate docstring test
* update flake call
* do not fail on docstring
* refactor setup into workflow
* update reference
* switch to action
* resturcture
* add bash statements
* remove os from cache
* update input checks
* make code cleaner
* fix boolean
* no relative paths
* install wheel by python
* switch to install
* revert back to simple wheel
* refactor import export tests
* move setup keys back to not disturbe tests
* remove docstyle till that is fixed
* update references
* continue on error
* use relativ action references
* Change step / job docstrings
* Improve error management for order price calculation
- If there are missing exchange rates, it throws an error
- Very much an edge case
* Style fixes
* Add warning message if total order price cannot be calculated
* price -> cost
* Enable 'tree view' for build order table
* Ensure we pass locale code to the build table
* Adjust button class based on current context
* Fix display of 'child builds' table on build page
* Force a rebuild of the entire table when the filters are refreshed
* Refactor PurchaseOrder table also
* Refactor existing SalesOrder table also
* JS linting
* Refactor 'DeleteManufacturerPart' form
- Remove duplicated forms
- Update style to match other forms
- Block on each deletion before progressing to the next one
* PEP fix
* Adds deleteSupplierParts function
* Refactor all instances of supplier part deletion
* Refactor tractor : use convenience function for bootstraptable.getSelections
* Add deleter for manufacturerpartparameter.
Refactor existing code into a single function
* Refactor deletion for stock items
* JS linting
* Adds two new fields to SalesOrderShipment model:
- Invoice number (char)
- Link (URL)
* Bump API version
* Update API / serializer / JS
- Allow entry of new fields at time of shipping
* PEP fixes
* Actually fix the PEP issues
* Unit testing: check some more fields