From acebe61ac597d3d6ca33ec60b7dfea9da39f8975 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 13 Apr 2020 16:41:17 +1000 Subject: [PATCH] Add 'manufacturer' field to SupplierPart object - ForeignKey link to Company model --- InvenTree/company/api.py | 3 ++- InvenTree/company/migrations/0015_company_is_manufacturer.py | 2 +- InvenTree/company/models.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index c7c8b153a4..70a24f0d8b 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -115,7 +115,8 @@ class SupplierPartList(generics.ListCreateAPIView): filter_fields = [ 'part', - 'supplier' + 'supplier', + 'manufacturer', ] search_fields = [ diff --git a/InvenTree/company/migrations/0015_company_is_manufacturer.py b/InvenTree/company/migrations/0015_company_is_manufacturer.py index bf7d23ebe9..b1e74667c2 100644 --- a/InvenTree/company/migrations/0015_company_is_manufacturer.py +++ b/InvenTree/company/migrations/0015_company_is_manufacturer.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='company', name='is_manufacturer', - field=models.BooleanField(default=True, help_text='Does this company manufacture parts?'), + field=models.BooleanField(default=False, help_text='Does this company manufacture parts?'), ), ] diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index 75d52893a4..5e59b512d1 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -265,7 +265,7 @@ class SupplierPart(models.Model): related_name='manufactured_parts', limit_choices_to={'is_manufacturer': True}, help_text=_('Select manufacturer'), - null=True, blank=True, + null=True, blank=True ) manufacturer_name = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer')) @@ -296,7 +296,7 @@ class SupplierPart(models.Model): items = [] if self.manufacturer: - items.append(self.manufacturer) + items.append(self.manufacturer.name) if self.MPN: items.append(self.MPN)