Repository navigation
Description
Please verify that this bug has NOT been raised before.
- I checked and didn't find a similar issue
Describe the bug*
Newly introduced feature "custom user states" breaks existing installations.
When editing the "status code" for a stock item, a 500 error is raised:
Traceback (most recent call last):
File "/opt/inventree/env/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/opt/inventree/env/lib/python3.10/site-packages/rest_framework/generics.py", line 288, in patch
return self.partial_update(request, *args, **kwargs)
File "/opt/inventree/env/lib/python3.10/site-packages/rest_framework/mixins.py", line 82, in partial_update
return self.update(request, *args, **kwargs)
File "/opt/inventree/src/backend/InvenTree/InvenTree/mixins.py", line 36, in update
self.perform_update(serializer)
File "/opt/inventree/env/lib/python3.10/site-packages/rest_framework/mixins.py", line 78, in perform_update
serializer.save()
File "/opt/inventree/src/backend/InvenTree/InvenTree/serializers.py", line 295, in save
super().save(**kwargs)
File "/opt/inventree/env/lib/python3.10/site-packages/rest_framework/serializers.py", line 207, in save
self.instance = self.update(self.instance, validated_data)
File "/opt/inventree/src/backend/InvenTree/stock/serializers.py", line 495, in update
return super().update(instance, validated_data)
File "/opt/inventree/src/backend/InvenTree/generic/states/fields.py", line 161, in update
reference = get_logical_value(
File "/opt/inventree/src/backend/InvenTree/generic/states/custom.py", line 43, in get_logical_value
return InvenTreeCustomUserStateModel.objects.get(key=value, model__model=model)
File "/opt/inventree/env/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/inventree/env/lib/python3.10/site-packages/django/db/models/query.py", line 637, in get
raise self.model.DoesNotExist(
common.models.InvenTreeCustomUserStateModel.DoesNotExist: InvenTreeCustomUserStateModel matching query does not exist.
Note that no "custom states" have been defined
Steps to Reproduce
- Edit stock item and change the "status" code
- Press "Submit"
- Error occurs
Expected behaviour
New status code should be accepted. No custom states should be required for this to work.
Deployment Method
- Docker
- Package
- Bare metal
- Other - added info in Steps to Reproduce
Version Information
Version Information:
InvenTree-Version: 0.17.0 dev
Django Version: 4.2.15
Commit Hash: bbf1198
Commit Date: 2024-08-22
Commit Branch: master
Database: mysql
Debug-Mode: True
Deployed using Docker: False
Platform: Linux-5.19.0-1029-aws-x86_64-with-glibc2.35
Installer: GIT
Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.1.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.1.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}, {'name': 'Wireviz', 'slug': 'wireviz', 'version': '0.6.2'}, {'name': 'KiCadLibraryPlugin', 'slug': 'kicad-library-plugin', 'version': '1.4.2'}, {'name': 'AOI Reporting', 'slug': 'aoi', 'version': '0.27.1'}, {'name': 'ESC Commissioning', 'slug': 'esccommissioning', 'version': '0.27.1'}, {'name': 'ESC Parameter Validation', 'slug': 'esc_parameters', 'version': '0.27.1'}, {'name': 'Purchase Order Reports', 'slug': 'poreports', 'version': '0.27.1'}, {'name': 'Serial Number Tags', 'slug': 'serial_tags', 'version': '0.27.1'}, {'name': 'Currawong Validation', 'slug': 'currawongvalidation', 'version': '0.27.1'}]
Please verify if you can reproduce this bug on the demo site.
- I can reproduce this bug on the demo site.
Relevant log output
No response


Activity
matmair commentedon Aug 23, 2024
I can not reproduce this; do you have more information about this instance? There is 98% coverage on #7862 and all API logic changes are fully covered
wolflu05 commentedon Aug 23, 2024
Silly question, but have you run the migrations?
SchrodingersGat commentedon Aug 23, 2024
Yes, migrations were all applied and up to date. I will look into this over the weekend further.
[-]User Defined States Issue[/-][+][BUG] User Defined States Issue[/+]matmair commentedon Aug 23, 2024
I have found a reproducible state; will submit patch
Add e2e test case for error condition
Fix state changes on stock items (inventree#7976)