Merge pull request from eeintech/manufacturer_part_api_fix

API fixes related to ManufacturerPart
This commit is contained in:
Oliver 2021-05-01 08:26:32 +10:00 committed by GitHub
commit 94ff8829f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

@ -131,7 +131,7 @@ class ManufacturerPartList(generics.ListCreateAPIView):
params = self.request.query_params
# Filter by manufacturer
manufacturer = params.get('company', None)
manufacturer = params.get('manufacturer', None)
if manufacturer is not None:
queryset = queryset.filter(manufacturer=manufacturer)

@ -192,10 +192,11 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
manufacturer_id = self.initial_data.get('manufacturer', None)
MPN = self.initial_data.get('MPN', None)
if manufacturer_id or MPN:
kwargs = {'manufacturer': manufacturer_id,
'MPN': MPN,
}
if manufacturer_id and MPN:
kwargs = {
'manufacturer': manufacturer_id,
'MPN': MPN,
}
supplier_part.save(**kwargs)
return supplier_part

@ -100,7 +100,7 @@ class ManufacturerTest(InvenTreeAPITestCase):
self.assertEqual(response.data['MPN'], 'MPN_TEST')
# Filter by manufacturer
data = {'company': 7}
data = {'manufacturer': 7}
response = self.get(url, data)
self.assertEqual(len(response.data), 3)