Commit Graph

14913 Commits

Author SHA1 Message Date
Oliver
a1cb954cb0
Readme sponsors (#5789)
* Add sponsors action

- Automatically show list of project sponsors
- Ref: https://github.com/JamesIves/github-sponsors-readme-action

* Update README.md

* Pin workflow action versions
2023-10-26 17:35:18 +11:00
Matthias Mair
02d55b9c87
Squashed commit of the following: (#5785)
commit 5e8ea099068475fd257d8c172348dc6f3edf9bcf
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 09:22:38 2023 +0200

    Update ui_plattform.spec.ts

commit 49da3312beff7fd6837ea741e621df221c445d19
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 07:56:25 2023 +0200

    more logging

commit 5337be4c3990051b805a6fce2e79ca4030b4afe5
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 07:56:11 2023 +0200

    added filter method for undefined settings that overwrite defaults

commit 5df8a0b3e77cd5dcf04c39ad7638ac845df75e4c
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 03:05:06 2023 +0200

    you do not need to string a string

commit 0650d3b3a0132889c2a76de38db38224e974d205
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 03:04:34 2023 +0200

    fix things that were borken for no good reason

commit a40dbfd1364cf01465037350184f59d2a2a8afab
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 02:39:34 2023 +0200

    reduce unneeded blocking timeouts

commit bf9046a5361ae919e70662e717d6156434b6fe43
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 02:34:10 2023 +0200

    catch server fetching errors

commit aa01e67e8c8e789fdf755ac4481e730fe5ea4183
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 02:33:29 2023 +0200

    move init as things are now plugged together different

commit 290c33bd3125d50779497d6fc5981d5813b58f5d
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Oct 24 01:49:32 2023 +0200

    do not log a failed automatic login try - why would you?
2023-10-26 07:55:52 +11:00
Oliver
e13b57669c
Barcode app docs (#5788)
* Update settings page

* Update barcode action documentation

* Update app privacy information
2023-10-25 23:46:26 +11:00
Oliver
f280e0aeaf
Update sales_order.js (#5784)
Typo fix
2023-10-25 12:24:30 +11:00
Oliver
dfc4fa7584
Fixes for table rendering (#5782)
- Handle case where related object does not exist in the dataset
2023-10-25 11:45:00 +11:00
Matthias Mair
8308f36923
bump action versions (#5776) 2023-10-25 09:18:53 +11:00
Oliver
679b49b4f7
Frontend server settings (#5765)
* Update ApiToken model

- Add metadata
- Remove unique_together requirement
- Add last_seen field

* Update admin page for token

* Store metadata against token on creation

* Track last-seen date

* Allow match against existing valid token

- If token is expired or revoked, create a new one
- Prevents duplication of tokens

* Update unit tests

* Fix default server

* Improve functionality for extracting frontend settings

* Update default server list

* Use f-strings

* Revert logger name

* Remove mark_safe warning
2023-10-23 22:33:16 +11:00
Oliver
39c499622d
Part responsible owner (#5774)
* Add "responsible_owner" field to part model

- Will replace "responsible" field

* Data migration

- Adds 'responsible_owner' value for parts which have 'responsible' set
- Selects correct content type
- Performs reverse migratoin

* Update part serializer

- Point to the new field
- Rename to preserve compatibility
- OPTIONS metadata will take care of the rest

* Remove old 'responsible' field

* Bump API version

* Fix typo

* Fix serializer field
2023-10-23 21:35:51 +11:00
Oliver
2dfe2d97bc
plugin hash - reduce error outputs (#5772)
* plugin hash - reduce error outputs

- If database is migrating, or not ready, don't log exception
- Ref: https://github.com/inventree/inventree-app/actions/runs/6604140572/job/17937959893

* Improve imports

* Further import improvements

* Typo fix
2023-10-23 10:01:28 +11:00
Oliver
d03927dea4
Fix imports in inventree_extras.py (#5770)
- Can cause a circular import
- Ref: https://github.com/inventree/inventree-app/actions/runs/6603924590/job/17937528806
2023-10-23 00:31:02 +11:00
Oliver
4d79c9f985
Add admin filters for ApiToken (#5768) 2023-10-21 22:48:41 +11:00
Oliver
b335728e29
Fix admin site - Custom admin URL (#5766)
* Update config template file

* Add entry to docs

* Add INVENTREE_ADMIN_ENABLED to settings.py

* Add helper functions for improving admin links

* Refactor existing admin links

* remove debug statements

* Fix custom admin URL

* Expand documentation

* Fix URL

* Improve wording in config_template.yaml

* Extend admin_url tag

- Allow lookup without pk
- Handle case where pk not found
2023-10-21 22:12:14 +11:00
Oliver
388b722de1
Handle case where 'title' does not exist (#5767) 2023-10-21 21:35:51 +11:00
Oliver
f0f4a20f4e
More token tweaks (#5764)
* Update ApiToken model

- Add metadata
- Remove unique_together requirement
- Add last_seen field

* Update admin page for token

* Store metadata against token on creation

* Track last-seen date

* Allow match against existing valid token

- If token is expired or revoked, create a new one
- Prevents duplication of tokens

* Update unit tests
2023-10-21 15:10:11 +11:00
Oliver
3b6c941f65
Token tweaks (#5761)
* Ensure token name is trimmed

* Improve sanitizing of token name
2023-10-20 20:39:53 +11:00
Matthias Mair
47964d24c0
Fixed PlaygroundArea accordion behaviour (#5760) 2023-10-20 17:16:54 +11:00
Oliver
23ea746813
Api token updates (#5664)
* Create new APIToken model

- Has custom 'name' field
- Has custom expiry date

* Add data migration to port across any existing user tokens

* Adds 'revoked' field - tokens can be manually revoked

* Update API token - allow multiple tokens per user

* Custom token auth handler

- Correctly handles revoked tokens
- Correctly handles expired tokens

* Update AuthRequiredMiddleware

- Check for token active status

* Token API endpoint improvements

- Can return tokens with custom names
- Return more information on the token too

* Consolidate migrations

* When requesting a token, overwrite inactive token for authenticated user

- An authenticated user must receive a token
- Unauthenticated users cannot do this

* Fix

* Use token name for frontend

* Force token expiry, and generate default expiry date

* Force generation of a new token when requested

* Reduce data exposed on token API endpoint

* Display redacted token in admin site

* Log when new token is created for user

* Add default value for token

- Allows raw token to be viewed in the admin interface when created
- After created, no longer visible
- Also provides ability to generate token with static prefix

* Fixes for admin interface

- Prevent user and expiry from being edited after creation

* Implement unit tests for token functionality

* Fix content exclude for import/export

* Fix typo

* Further tweaks

- Prevent editing of "name" field after creation
- Add isoformat date suffix to token

* Longer token requires longer database field!

* Fix other API tokens

* Remove 'delete' method from token API endpoint

* Bump API version
2023-10-20 14:06:06 +11:00
Oliver
25138300ff
New Crowdin updates (#5758)
* updated translation base

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

* Fix: New translations django.po from Crowdin

* Fix: New translations messages.po from Crowdin

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-20 12:48:42 +11:00
Oliver
e57b69be48
React UI improvements (#5756)
* Add CompanyDetail page

* Add "edit company" button (and associated form)

* Implement dropdown actions for company page

* Update actions for PartDetail

* Adds overlay while modal is loading

- Lets the user know that something is at least happening in the background

* Update panels

* Implement separate pages for different company types

- Mostly for better breadcrumbs

* Placeholder actions for build detail

* Add stock table to company page

* typescript linting

* Fix unused variables

* remove dodgy improt
2023-10-20 00:23:58 +11:00
Bobbe
ae063d2722
Add basic support for scanning vendor barcodes (#5509)
* Add support for scanning digikey and mouser barcodes

* added small fixes if no part is found

* made small style cleanups

* Separate out ecia 2d barcode parser, Add quantity, PO number to response

* Use model instead of name for mouser supplier, add auto detection magic

* Add lcsc barcode support

* Move barcode plugins to new suppliers subdirectory

* Add get_supplier_part helper, Refactor plugins in preparation for #3791

* Add __init__.py to suppliers directory

* Improve formatting

* Add barcode integration tests

* Add api-barcode-po-receive endpoint

* Refactor supplier_barcode.py helpers into BarcodeMixin

* Implement the api-barcode-po-receive endpoint for all suppliers

* Always include lineitem in api response

* Fix location in response, only include quantity and location if set

* Check if barcode has already been assigned, Fix tests

* FIx quantity and location not being in lineitem reponse

* Use part.get_default_location() instead of part.default_location

* Fix fomatting again

* Fix type annotations for python 3.8

* Add get_supplier_part helper, check for barcode_data being a str

* Fix naming clash

* Clarify return type for scan_receive_item

* Improve model access using first() in two places

* Refactor a bunch of checks

* Improve selection of line item, if multiple line items match the SKU

* Add new api version for this PR

* Fix error if no line item exists

* Add debug print to investigate why tests are failing

* Remove the test print again

* Fix pre formatted log messages

* Test removing all plugins

* Test only with digikey plugin

* Test with all plugins, but without mouser "model" setting

* Test again without tests

* Test with simple tests

* Test with simple receive test

* Test with even more receive tests

* Test second receive test

* Test third receive test

* Test 4th receive test with debug prints

* Try deleting the stock item and stock locations

* Disable the test again

* Add SupplierBarcodeMixin to minimize shared code between plugins

* Add TME supplier barcode plugin

* Remove the TME tests again

* If this works the tests are broken, if this doesn't work the tests are broken too

* Add TME tests again

* Add back all tests again

* Fix TME purchase order number

* Fix TME qrcode regex

* Add documentation for this feature

* Fix TME qrcode regex

* Use Decimal instead of int for quantity

* Refactor get_supplier_parts, Add get_supplier method

* Improve docstrings

* Fix None type access

* FIx TME barcode detection, Improve supplier barcode handling

* Try to retrigger pipeline

* Refactor get_supplier_parts to not use lists

* Add DEFAULT_SUPPLIER_NAME to mouser plugin

* Add SUPPLIER_ID setting to other suppliers

* Fix supplier plugins not inheriting from settings mixin

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
2023-10-19 23:28:21 +11:00
Oliver
2be5ec26f8
[React] Login improvements (#5752)
* Logout user if user query fails

* login / logout improvements

- Add timeout to request (otherwise hangs indefinitely)

* Improve "checking login" page

* Update login form

- Disable button if logging in
- Show loader

* Fixed unused vars
2023-10-19 13:42:12 +11:00
Oliver
566fef5309
[React] Purchasing and Sales (#5743)
* Skeleton layout for purchasing and sales

- Empty pages
- Nav links
- Tab panels

* Add <CompanyTable> component

- Customers
- Suppliers
- Manufacturers

* Table fxies

* Initial implementation of PurchaseOrderTable

* More tables

- Basic SalesOrderTable
- Basic ReturnOrderTable

* Improvements to InvenTreeTable component

- Handle incorrect return type from server
- Use state for recordCount

* Formatting fixes
2023-10-19 10:11:04 +11:00
Matthias Mair
543d50149b
Added python test paths to deepsource (#5738)
* Added python test paths to deepsource

* Added test files

* added "tests" too
2023-10-19 07:43:50 +11:00
Oliver
3349013646
[React] Improvements to API forms (#5742)
* Remove read_only field from API OPTIONS

- 'read_only' is a reserved field for some Mantine components

* Fixing further errors for related field model

* Handle bad values for numericalValue

* Fix for default values for API forms

* Fix for choice field

- Do not set form default value when constructing element

* Tweak for PartDetail page
2023-10-18 14:45:03 +11:00
Oliver
cb33705e44
Adds 'A3' as report size option (#5733) 2023-10-18 14:27:07 +11:00
Matthias Mair
fda909ac59
Fix news dashboard (#5741)
* Fixes wrong news url

* Typed dashboard items

* Removed double trailing slashes
2023-10-18 09:07:13 +11:00
Matthias Mair
eb79bd1743
refactor: refactor unnecessary else / elif when if block has a return statement (#5735)
The use of `else` or `elif` becomes redundant and can be dropped if the last statement under the leading `if` / `elif` block is a `return` statement.
In the case of an `elif` after `return`, it can be written as a separate `if` block.
For `else` blocks after `return`, the statements can be shifted out of `else`. Please refer to the examples below for reference.

Refactoring the code this way can improve code-readability and make it easier to maintain.

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2023-10-18 09:06:54 +11:00
Matthias Mair
3f93151cca
refactor: replace multiple == checks with in (#5737)
To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained `in` it instead of checking for equality against each of the values.
This is faster, less verbose, and more readable.

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2023-10-18 07:30:16 +11:00
Matthias Mair
faac6b6bf5
refactor: remove blank lines after docstring (#5736)
There shouldn't be any blank lines after the function docstring.
Remove the blank lines to fix this issue.

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2023-10-18 07:28:57 +11:00
Matthias Mair
158a209a0f
Version bump (#5740)
* Updated all dependencies

* fixed some spelling errors

* More spelling corrections

* Fixes for changes in react-query
2023-10-18 07:27:28 +11:00
Bobbe
9f2c55d2d6
Allow stock items to be reallocated for build items (#5693)
* Allow stock items to be reallocated for build items

* Refactor create check

* Fix quantity calculation, Add tests
2023-10-18 00:48:30 +11:00
Oliver
8c10b98fe8
[React] Update part parameters table (#5731)
* Implement simple "PartVariantTable" component

- Not yet nested
- More work needed for table nesting

* Fix issue rendering same image multiple times

- Use useId hook to generate random key

* Update PartParameter list API endpoint

- Allow part_detail extra field
- Add FilterSet class
- Allow filter to include variants

* Update PartParameterTable

- Display part column
- Allow returned parts to include templates of base part
- Hide actions for templated parameters

* Fix some code smells
2023-10-18 00:41:05 +11:00
Oliver
997b2ad569
Remove --no-frontend option (#5568)
- Until the new frontend is fully ready to be shipped, adding this option only serves to confuse users (and break the install process potentially)
- Remove this option entirely from the invoke script
- Update documentation accordingly
2023-10-18 00:21:26 +11:00
Oliver
4bbf168393
Use full width (#5728)
- Wasting a lot of space on larger screen
2023-10-17 22:53:59 +11:00
Oliver
1b7f943946
Prefetch RuleSet objects for group (#5725)
* Prefetch RuleSet objects for group

- Prevent multiple unnecessary db queries

* Tweak

* Default to previous behavior

* Revert closer to original
2023-10-17 21:33:23 +11:00
Oliver
ccaece3634
Remove StockItemManager class (#5727)
- Not used anywhere
- Reference: https://github.com/inventree/InvenTree/issues/5586
2023-10-17 21:21:13 +11:00
Oliver
550d549325
Refactor plugin loading (#5726)
- Pre-fetch all PluginConfig objects
- Only update plugin config active status when changed
- Reference: https://github.com/inventree/InvenTree/issues/5586
2023-10-17 21:07:16 +11:00
Oliver
e3fef5b226
Improve checks for scheduled tasks at startup (#5724)
- Only update or create tasks if necessary
- Perform bulk_create and bulk_update operations
- Reduce to N(1) - independent of how many tasks we add in the future

Ref: https://github.com/inventree/InvenTree/issues/5586
2023-10-17 16:05:43 +11:00
Oliver
7ff5654448
Cache default currency (#5723)
- Prevents multiple (failing) database hits during server startup
- Prevents multiple (failing) database hits during migration checks
2023-10-17 15:50:05 +11:00
Oliver
8f75758c45
Fix money field kwargs (#5722)
- Reduces number of calls to currency_code_defaults()
- Thus reducing number of database hits

(cherry picked from commit 15ff99a24d2a4dcbe38cf4f2c7b886c8820952e8)
2023-10-17 15:22:19 +11:00
Oliver
a566ac67a7
BOM Table - Fix pricing when subassembly is open (#5721)
- Ignore pricing for sub-items
- Fixes https://github.com/inventree/InvenTree/issues/5286
2023-10-17 14:12:32 +11:00
Oliver
c74368f805
Fix typo (#5715)
* Fix typo

getSpashScren -> getSplashScreen

* Cleanup docs
2023-10-17 12:12:22 +11:00
Peter Kopias
40fb1329bb
add /static/ relative comment and update splash image path in config_template.yaml (#5433)
* add /static/ relative comment and update splash image path in config_template.yaml

* Update config_template.yaml

Fix paths

---------

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2023-10-17 11:25:05 +11:00
Matthias Mair
40ff0e1060
Add deepsource for more security testing (#5714)
* Added deepsource for SAST testing and more
Closes https://github.com/inventree/org/issues/41

* Add deepsource badges to Readme
2023-10-17 11:23:19 +11:00
Oliver
8bc750bc06
[React] Settings interface (#5679)
* Add some dummy pages for settings

* Add some placeholder pages for settings

* Refactor 'useInstance' hook

- Allow use without a pk

* Make response status code available

* Cleanup user settings page

* Fill out (empty) panels for system settings

* Update URLs

* Add more user information to "me" API endpoint

* Implement global user context

- User information available globally
- Add placeholder page for plugin settings

* remove debug entry

* Add first-pass implementation of plugins table

* Add icon to plugin table

* plugin table improvements

* Add SettingsContext component

- Allows list of settings to be drilled down through props
- Also provides a way of reloading the settings list

* Update settings page

* Update settings detail API endpoints

- No longer case sensitive

* Display boolean values, and allow them to be edited

- Still some work to be done here
- Need to pass the base URL down through useContext

* Allow editing of non-boolean settings too

- Required some adjustment to existing forms interface

* Fix rendering of choice field within modal

* Display correct value for choice fields

* Expose settings units to API

* Updates

- Display units for setting (if available)
- Rename fieldType to field_type
- React does not like snakeCase props

* Improve form handling

* Add global server settings keys

* Add table for project codes

* Use cache to ensure that settings are not rebuilt too often

* Update api version notes

* Add username helper function to user state

* Remove SettingsContext

- Replace with global state manager
- Does not currently refresh properly

* Remove UserContext

* Update BaseContext

* Cleanup to match master

- Integrated many improvements from current master

* Get settings items working again

- Now integrates nicely with userSettingsState and globalSettingsState

* Improve generation of user name

* Handle user settings too

* url endpoint fix

* Add new table for custom unit management

* Update global settings
2023-10-17 10:28:46 +11:00
Michael
f409cd6894
Added example for barcode plugin (#5670)
* Added example for barcode plugin

* Add some words in stock location reports

* Correct error in link

* Correct error in link

* Typo in link

* Style in code example
2023-10-17 10:24:05 +11:00
Oliver
d98b1bb2c7
Fix <YesNoButton> (#5711)
- Add missing destructuring
2023-10-17 00:54:55 +11:00
Oliver
80a170d93c
Improve useInstance hook (#5710)
- Allow use without primary key
- Allow default value to be customizedr
2023-10-16 23:54:28 +11:00
Oliver
9705521cd2
[React] Part parameters table (#5709)
* Track current panel selection in local storage

* Simplify part detail tabs

* Fix <PanelGroup> instances

* Handle missing model type for rendering

* Add some more API endpoints

* Add PartParameter table

* Add callback to create new part parameter

* Allow PartParameter list API endpoint to be searched

* More PanelGroup collapse tweaks

- Still requires more attention

* Fix logic for related part table

- Need to rebuild columns when part id changes

* Further fixes for related part table

* Re-implement change to PanelGroup

- useLocalStorage
- Change got clobbered in recent merge conflict

* Add part thumbnail to StockItemTable

* Add simple <YesNo> button

- Can be improved later

* Fix for PartTable

* Allow CORS requests to /static/ endpoint

* Updates to other existing tables

* Update URLs for dashboard items
2023-10-16 23:34:16 +11:00
Oliver
a9d18ba28f
Improved implementation of panel collapse (#5708)
* Improved implementation of panel collapse

* Slight tweaks
2023-10-16 20:34:21 +11:00