Commit Graph

44 Commits

Author SHA1 Message Date
Joe Rogers c18bc4e1d1
Fix: Allow allocation of variants to sales order lines (#5656)
* Add tests for allocating a variant to a sales order line

* Add check for variants to match template allocation

* Tweak fixtures for inventree-python, improve test checks

* Optimize check for item variants
2023-10-04 10:39:22 +11:00
Oliver 6ba777d363
Build Order Updates (#4855)
* Add new BuildLine model

- Represents an instance of a BOM item against a BuildOrder

* Create BuildLine instances automatically

When a new Build is created, automatically generate new BuildLine items

* Improve logic for handling exchange rate backends

* logic fixes

* Adds API endpoints

Add list and detail API endpoints for new BuildLine model

* update users/models.py

- Add new model to roles definition

* bulk-create on auto_allocate

Save database hits by performing a bulk-create

* Add skeleton data migration

* Create BuildLines for existing orders

* Working on building out BuildLine table

* Adds link for "BuildLine" to "BuildItem"

- A "BuildItem" will now be tracked against a BuildLine
- Not tracked directly against a build
- Not tracked directly against a BomItem
- Add schema migration
- Add data migration to update links

* Adjust migration 0045

- bom_item and build fields are about to be removed
- Set them to "nullable" so the data doesn't get removed

* Remove old fields from BuildItem model

- build fk
- bom_item fk
- A lot of other required changes too

* Update BuildLine.bom_item field

- Delete the BuildLine if the BomItem is removed
- This is closer to current behaviour

* Cleanup for Build model

- tracked_bom_items -> tracked_line_items
- untracked_bom_items -> tracked_bom_items
- remove build.can_complete
- move bom_item specific methods to the BuildLine model
- Cleanup / consolidation

* front-end work

- Update javascript
- Cleanup HTML templates

* Add serializer annotation and filtering

- Annotate 'allocated' quantity
- Filter by allocated / trackable / optional / consumable

* Make table sortable

* Add buttons

* Add callback for building new stock

* Fix Part annotation

* Adds callback to order parts

* Allocation works again

* template cleanup

* Fix allocate / unallocate actions

- Also turns out "unallocate" is not a word..

* auto-allocate works again

* Fix call to build.is_over_allocated

* Refactoring updates

* Bump API version

* Cleaner implementation of allocation sub-table

* Fix rendering in build output table

* Improvements to StockItem list API

- Refactor very old code
- Add option to include test results to queryset

* Add TODO for later me

* Fix for serializers.py

* Working on cleaner implementation of build output table

* Add function to determine if a single output is fully allocated

* Updates to build.js

- Button callbacks
- Table rendering

* Revert previous changes to build.serializers.py

* Fix for forms.js

* Rearrange code in build.js

* Rebuild "allocated lines" for output table

* Fix allocation calculation

* Show or hide column for tracked parts

* Improve debug messages

* Refactor "loadBuildLineTable"

- Allow it to also be used as output sub-table

* Refactor "completed tests" column

* Remove old javascript

- Cleans up a *lot* of crusty old code

* Annotate the available stock quantity to BuildLine serializer

- Similar pattern to BomItem serializer
- Needs refactoring in the future

* Update available column

* Fix build allocation table

- Bug fix
- Make pretty

* linting fixes

* Allow sorting by available stock

* Tweak for "required tests" column

* Bug fix for completing a build output

* Fix for consumable stock

* Fix for trim_allocated_stock

* Fix for creating new build

* Migration fix

- Ensure initial django_q migrations are applied
- Why on earth is this failing now?

* Catch exception

* Update for exception handling

* Update migrations

- Ensure inventreesetting is added

* Catch all exceptions when getting default currency code

* Bug fix for currency exchange rates update

* Working on unit tests

* Unit test fixes

* More work on unit tests

* Use bulk_create in unit test

* Update required quantity when a BuildOrder is saved

* Tweak overage display in BOM table

* Fix icon in BOM table

* Fix spelling error

* More unit test fixes

* Build reports

- Add line_items
- Update docs
- Cleanup

* Reimplement is_partially_allocated method

* Update docs about overage

* Unit testing for data migration

* Add "required_for_build_orders" annotation

- Makes API query *much* faster now
- remove old "required_parts_to_complete_build" method
- Cleanup part API filter code

* Adjust order of fixture loading

* Fix unit test

* Prevent "schedule_pricing_update" in unit tests

- Should cut down on DB hits significantly

* Unit test updates

* Improvements for unit test

- Don't hard-code pk values
- postgresql no likey

* Better unit test
2023-06-13 20:18:32 +10:00
Matthias Mair 21ed4b2081
Fix common spelling mistakes (#4956)
* add codespell

* first fixes

* doc fixes

* fix docstrings and comments

* functional changes

* docstrings again

* and docs again

* rename args

* add ignore

* use pre-commit for filtering instead

* ups

* fix typo in filter
2023-06-04 00:04:52 +10:00
miggland 1d85b70313
Add Metadata to more models (#4898)
* Update models: add MetadataMixin

* Fix name of model in Metadata API definition

* Add API endpoints

* Update API version

* Fix syntax

* Add API endpoint for RO, RO line, RO line extra item

* Add Metadata to Contacts

* Fix link in API version

* Fix name of model

* Fix error?

* Fix error?

* Fix all errors, hopefully..

* Add tests for order, line, extraline metadata

Extend for PO, SO

* Add tests for metadata for Company-related models

* Fix spelling

* Consolidate metadata test for all part models into one test

* Add test for all Stock metadata

* Update stock test_api

* Add all metadata tests for orders

* Fix various errors in tests

* Fix model name

* Add migration files

* Update tests for metadata

* Resolve conflict around API version number

* Rename migration file

* Rename migration file

* Will Contact edit endpoint work better?

* Revert changes in URL definitions

* Remove test, duplicate

* Fix tests with fixed PK, not from fixtures, to use a dynamic PK

* Fix migration overlap
2023-06-02 19:26:20 +10:00
Oliver abeb85cbb3
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
2023-03-07 22:43:12 +11:00
Oliver 4f029d4d81
Improvements for part creation API endpoint (#4281)
* Refactor javascript for creating a new part

* Simplify method of removing create fields from serializer

* Fix bug which resulted in multiple model instances being created

* remove custom code required on Part model

* Reorganize existing Part API test code

* Add child serializer for part duplication options

* Part duplication is now handled by the DRF serializer

- Improved validation options
- API is self-documenting (no more secret fields)
- More DRY

* Initial stock is now handled by the DRF serializer

* Adds child serializer for adding initial supplier data for a Part instance

* Create initial supplier and manufacturer parts as specified

* Adding unit tests

* Add unit tests for part duplication via API

* Bump API version

* Add javascript for automatically extracting info for nested fields

* Improvements for part creation form rendering

- Move to nested fields (using API metadata)
- Visual improvements
- Improve some field name / description values

* Properly format nested fields for sending to the server

* Handle error case for scrollIntoView

* Display errors for nested fields

* Fix bug for filling part category

* JS linting fixes

* Unit test fixes

* Fixes for unit tests

* Further fixes to unit tests
2023-02-02 09:24:16 +11:00
Oliver 0787264930
Allow searching of BOM List API endpoint (#3296)
* Allow searching of BOM List API endpoint

* Bump API version

* Adds ordering field options to BOM List API endpoint

* Add some unit testing for new API features

* Fixes for unit tests
2022-07-06 10:09:58 +10:00
Matthias Mair 74726f0fda fix endline 2022-05-20 13:35:07 +02:00
Matthias Mair 93b6934127 fix trailing 2022-05-20 13:20:55 +02:00
Oliver ee47be4c9e Add unit test for 'available_variant_stock' in BomItem API serializer 2022-04-26 17:05:21 +10:00
Oliver 70d4960fa3 Add new unit tests for part API filters 2022-04-26 11:43:34 +10:00
Oliver Walters f9a0bf822e Add more fixture data
- Stock items for part 100 (Bob)
2022-04-02 09:54:55 +11:00
Oliver bff9f0828a Adds API endpoint to allocate stock items against a SalesOrder
- SalesOrderAllocations are no longer created manually
- API endpoint performs data validation
- Multiple line items can be allocated at once
- Adds unit testing for new API endpoint
2021-10-26 23:51:36 +11:00
Oliver 75a35773c6 More unit tests 2021-10-04 20:44:15 +11:00
Oliver 979ef674d6 Update data for unit test fixtures 2021-06-22 13:24:03 +10:00
Matthias 3f04a57452 added test for internal prices 2021-06-13 15:01:03 +02:00
Matthias 3fb95bea7e added test for sell price breaks 2021-06-13 13:31:31 +02:00
Matthias d5b65e6e41 yaml! 2021-05-06 14:38:13 +02:00
Oliver Walters 8a06eaa40d Unit testing 2021-04-11 19:28:39 +10:00
Oliver Walters da02ab3eac Add unit testing for view 2021-01-05 00:01:44 +11:00
Oliver Walters d1ce0f062e Improve unit testing for StockItem API 2021-01-04 01:22:43 +11:00
Oliver Walters 47cbf3071d Add option to add a single-quantity price-break when creating a new SupplierPart object
- Add unit testing!
2020-11-12 21:36:32 +11:00
eeintech e401bb8e3c Improved tests, fixed admin, improved naming 2020-11-04 12:06:07 -05:00
Francois b1885138de
Merge branch 'master' into categories_parameters 2020-11-03 07:01:56 -05:00
Oliver Walters 2b91f69c7d Fix unit tests 2020-11-03 20:19:24 +11:00
eeintech 13a07be728 Added PartCategoryParameterTemplate tests 2020-11-02 15:35:54 -05:00
Oliver Walters 911727f7b7 Update test fixtures
- Can't assume that pk values will be assigned sensibly!
- Need to hard-code them in
2020-09-02 19:47:07 +10:00
Oliver Walters 95d07cd02b Add unit testing for new API features 2020-05-17 14:14:54 +10:00
Oliver Walters badf9230a9 Add fixtures / unit testing for the stock item testing framework 2020-05-17 13:46:19 +10:00
Oliver Walters 2d6c531fda Unit testing for part variant MPTT 2020-05-15 22:01:21 +10:00
Oliver Walters 0652579312 Update fixture for part model to match MPTT requirements 2020-05-15 21:44:25 +10:00
Oliver Walters 789712acbe Rename Build.URL -> Build.link 2020-04-06 11:28:35 +10:00
Oliver Walters e4fc44c135 More test 2019-09-08 20:36:51 +10:00
Oliver Walters 2a203be5cc Tests for part parameters 2019-09-08 20:18:21 +10:00
Oliver Walters dac61eafa2 Fixed tests
- Tree classes now need extra configuration in the fixture
- Check for null pk when cleaning a tree node
2019-09-08 19:41:54 +10:00
Oliver Walters 43967e302b Add ablity to serialize an existing quantity of stock
- Do not have to serialize all the stock
- Add tests
- Add function to copy entire stock transaction history
2019-08-28 21:12:16 +10:00
Oliver Walters bd61c89094 Tests for stock app views 2019-08-09 20:13:23 +10:00
Oliver Walters ba26acd487 Rename some fields
- Oops didn't think that through, gotta go through and fix the data now...
2019-06-02 19:46:30 +10:00
Oliver Walters f410957d8d Refactored Stock test to use fixtures 2019-05-12 21:46:38 +10:00
Oliver Walters fcc83ca7c7 Part API test suite now uses test data fixtures 2019-05-05 00:15:25 +10:00
Oliver Walters c0e3007e4f Add some BomItem tests
- Add a bom fixture
2019-05-04 23:50:24 +10:00
Oliver Walters 1f80e8c655 More tests for Part
- barcode
- category_path
2019-05-04 23:35:52 +10:00
Oliver Walters ab6673caa3 Add tests for default location traversal 2019-05-04 23:20:59 +10:00
Oliver Walters 6d803d48b5 Add fixtures to the part test
- Make development of further tests much easier
2019-05-04 22:58:55 +10:00