Skip to content

[BUG] User Defined States Issue #7964

Closed

Description

@SchrodingersGat

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:

image

image


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

  1. added
    bug
    question
    triage:not-checked
    on Aug 22, 2024
  2. removed
    question
    triage:not-checked
    on Aug 22, 2024
  3. added this to the 0.17.0 milestone on Aug 22, 2024
  4. matmair commented on Aug 23, 2024

    @matmair
    Member

    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

  5. wolflu05 commented on Aug 23, 2024

    @wolflu05
    Member

    Silly question, but have you run the migrations?

  6. SchrodingersGat commented on Aug 23, 2024

    @SchrodingersGat
    MemberAuthor

    Yes, migrations were all applied and up to date. I will look into this over the weekend further.

  7. changed the title [-]User Defined States Issue[/-] [+][BUG] User Defined States Issue[/+] on Aug 23, 2024
  8. matmair commented on Aug 23, 2024

    @matmair
    Member

    I have found a reproducible state; will submit patch

  9. added a commit that references this issue on Aug 23, 2024
    ee26300
  10. added a commit that references this issue on Aug 23, 2024
    ed2da62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions