Add 'manufacturer' field to SupplierPart object

- ForeignKey link to Company model
This commit is contained in:
Oliver Walters 2020-04-13 16:41:17 +10:00
parent e9e734acce
commit acebe61ac5
3 changed files with 5 additions and 4 deletions

View File

@ -115,7 +115,8 @@ class SupplierPartList(generics.ListCreateAPIView):
filter_fields = [ filter_fields = [
'part', 'part',
'supplier' 'supplier',
'manufacturer',
] ]
search_fields = [ search_fields = [

View File

@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='company', model_name='company',
name='is_manufacturer', 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?'),
), ),
] ]

View File

@ -265,7 +265,7 @@ class SupplierPart(models.Model):
related_name='manufactured_parts', related_name='manufactured_parts',
limit_choices_to={'is_manufacturer': True}, limit_choices_to={'is_manufacturer': True},
help_text=_('Select manufacturer'), help_text=_('Select manufacturer'),
null=True, blank=True, null=True, blank=True
) )
manufacturer_name = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer')) manufacturer_name = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer'))
@ -296,7 +296,7 @@ class SupplierPart(models.Model):
items = [] items = []
if self.manufacturer: if self.manufacturer:
items.append(self.manufacturer) items.append(self.manufacturer.name)
if self.MPN: if self.MPN:
items.append(self.MPN) items.append(self.MPN)