diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index a5f3361d38..eb0d7fc4e6 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -215,7 +215,7 @@ class SupplierPartList(generics.ListCreateAPIView): manufacturer = params.get('manufacturer', None) if manufacturer is not None: - queryset = queryset.filter(manufacturer=manufacturer) + queryset = queryset.filter(manufacturer_part__manufacturer=manufacturer) # Filter by supplier supplier = params.get('supplier', None) @@ -227,7 +227,7 @@ class SupplierPartList(generics.ListCreateAPIView): company = params.get('company', None) if company is not None: - queryset = queryset.filter(Q(manufacturer=company) | Q(supplier=company)) + queryset = queryset.filter(Q(manufacturer_part__manufacturer=company) | Q(supplier=company)) # Filter by parent part? part = params.get('part', None) @@ -298,7 +298,7 @@ class SupplierPartDetail(generics.RetrieveUpdateDestroyAPIView): - GET: Retrieve detail view - PATCH: Update object - - DELETE: Delete objec + - DELETE: Delete object """ queryset = SupplierPart.objects.all() diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index a2e5abdd9e..b904912cb2 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -400,7 +400,7 @@ class SupplierPart(models.Model): manufacturer_part = models.ForeignKey(ManufacturerPart, on_delete=models.CASCADE, blank=True, null=True, - related_name='manufacturer_parts', + related_name='supplier_parts', verbose_name=_('Manufacturer Part'), help_text=_('Select manufacturer part'), ) diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index 80734d2225..164f36a33d 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -82,7 +82,7 @@ class CompanySerializer(InvenTreeModelSerializer): class ManufacturerPartSerializer(InvenTreeModelSerializer): - """ Serializer for SupplierPart object """ + """ Serializer for ManufacturerPart object """ part_detail = PartBriefSerializer(source='part', many=False, read_only=True) @@ -131,7 +131,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer): supplier_detail = CompanyBriefSerializer(source='supplier', many=False, read_only=True) - manufacturer_detail = ManufacturerPartSerializer(source='manufacturer_part', many=False, read_only=True) + manufacturer_detail = CompanyBriefSerializer(source='manufacturer_part.manufacturer', many=False, read_only=True) pretty_name = serializers.CharField(read_only=True) @@ -158,9 +158,9 @@ class SupplierPartSerializer(InvenTreeModelSerializer): supplier = serializers.PrimaryKeyRelatedField(queryset=Company.objects.filter(is_supplier=True)) - manufacturer = ManufacturerPartSerializer(many=False, read_only=True) + manufacturer = serializers.PrimaryKeyRelatedField(source='manufacturer_part.manufacturer', queryset=Company.objects.filter(is_manufacturer=True)) - MPN = ManufacturerPartSerializer(many=False, read_only=True) + MPN = serializers.StringRelatedField(source='manufacturer_part.MPN', read_only=True) class Meta: model = SupplierPart diff --git a/InvenTree/company/templates/company/manufacturer_part_navbar.html b/InvenTree/company/templates/company/manufacturer_part_navbar.html index 31430e7e6e..07489d65ea 100644 --- a/InvenTree/company/templates/company/manufacturer_part_navbar.html +++ b/InvenTree/company/templates/company/manufacturer_part_navbar.html @@ -8,6 +8,13 @@ +