diff --git a/src/backend/InvenTree/part/helpers.py b/src/backend/InvenTree/part/helpers.py index ab20c795d7..fcd24b0f2e 100644 --- a/src/backend/InvenTree/part/helpers.py +++ b/src/backend/InvenTree/part/helpers.py @@ -7,6 +7,8 @@ from django.conf import settings from jinja2 import Environment, select_autoescape +from common.settings import get_global_setting + logger = logging.getLogger('inventree') @@ -20,14 +22,10 @@ def compile_full_name_template(*args, **kwargs): This function is called whenever the 'PART_NAME_FORMAT' setting is changed. """ - from common.models import InvenTreeSetting - global _part_full_name_template global _part_full_name_template_string - template_string = InvenTreeSetting.get_setting( - 'PART_NAME_FORMAT', backup_value='', cache=True - ) + template_string = get_global_setting('PART_NAME_FORMAT', cache=True) # Skip if the template string has not changed if ( diff --git a/src/backend/InvenTree/part/urls.py b/src/backend/InvenTree/part/urls.py index 35eca76837..9b05133607 100644 --- a/src/backend/InvenTree/part/urls.py +++ b/src/backend/InvenTree/part/urls.py @@ -3,7 +3,6 @@ Provides URL endpoints for: - Display / Create / Edit / Delete PartCategory - Display / Create / Edit / Delete Part -- Create / Edit / Delete PartAttachment - Display / Create / Edit / Delete SupplierPart """ diff --git a/src/backend/InvenTree/stock/serializers.py b/src/backend/InvenTree/stock/serializers.py index 3cfd845803..2e0c2d2531 100644 --- a/src/backend/InvenTree/stock/serializers.py +++ b/src/backend/InvenTree/stock/serializers.py @@ -391,6 +391,31 @@ class StockItemSerializer(InvenTree.serializers.InvenTreeTagModelSerializer): """ extra_kwargs = {'use_pack_size': {'write_only': True}} + def __init__(self, *args, **kwargs): + """Add detail fields.""" + part_detail = kwargs.pop('part_detail', False) + location_detail = kwargs.pop('location_detail', False) + supplier_part_detail = kwargs.pop('supplier_part_detail', False) + tests = kwargs.pop('tests', False) + path_detail = kwargs.pop('path_detail', False) + + super(StockItemSerializer, self).__init__(*args, **kwargs) + + if not part_detail: + self.fields.pop('part_detail') + + if not location_detail: + self.fields.pop('location_detail') + + if not supplier_part_detail: + self.fields.pop('supplier_part_detail') + + if not tests: + self.fields.pop('tests') + + if not path_detail: + self.fields.pop('location_path') + part = serializers.PrimaryKeyRelatedField( queryset=part_models.Part.objects.all(), many=False, @@ -547,31 +572,6 @@ class StockItemSerializer(InvenTree.serializers.InvenTreeTagModelSerializer): tags = TagListSerializerField(required=False) - def __init__(self, *args, **kwargs): - """Add detail fields.""" - part_detail = kwargs.pop('part_detail', False) - location_detail = kwargs.pop('location_detail', False) - supplier_part_detail = kwargs.pop('supplier_part_detail', False) - tests = kwargs.pop('tests', False) - path_detail = kwargs.pop('path_detail', False) - - super(StockItemSerializer, self).__init__(*args, **kwargs) - - if not part_detail: - self.fields.pop('part_detail') - - if not location_detail: - self.fields.pop('location_detail') - - if not supplier_part_detail: - self.fields.pop('supplier_part_detail') - - if not tests: - self.fields.pop('tests') - - if not path_detail: - self.fields.pop('location_path') - class SerializeStockItemSerializer(serializers.Serializer): """A DRF serializer for "serializing" a StockItem.