Coverage for src/backend/InvenTree/generic/states/custom.py: 75%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 17:47 +0000

1"""Helper functions for custom status labels.""" 

2 

3from InvenTree.helpers import inheritors 

4 

5from .states import ColorEnum, StatusCode 

6 

7 

8def get_custom_status_labels(include_custom: bool = True): 

9 """Return a dict of custom status labels.""" 

10 return {cls.tag(): cls for cls in inheritors(StatusCode)} 

11 

12 

13def state_color_mappings(): 

14 """Return a list of custom user state colors.""" 

15 return [(a.name, a.value) for a in ColorEnum] 

16 

17 

18def state_reference_mappings(): 

19 """Return a list of custom user state references.""" 

20 classes = inheritors(StatusCode) 

21 return [(a.__name__, a.__name__) for a in sorted(classes, key=lambda x: x.__name__)] 

22 

23 

24def get_logical_value(value, model: str): 

25 """Return the state model for the selected value.""" 

26 from common.models import InvenTreeCustomUserStateModel 

27 

28 return InvenTreeCustomUserStateModel.objects.get(key=value, model__model=model)