From e9e734acce4d5f2f3bfea2d0557594d54d42ed2d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 13 Apr 2020 13:29:11 +1000 Subject: [PATCH] Rename "manufacturer" to "manufacturer_name" --- InvenTree/company/api.py | 2 +- InvenTree/company/forms.py | 1 + .../migrations/0017_auto_20200413_0320.py | 18 ++++++++++++++++++ InvenTree/company/models.py | 11 +++++++++-- InvenTree/company/serializers.py | 1 + 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 InvenTree/company/migrations/0017_auto_20200413_0320.py diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index 4231dc8434..c7c8b153a4 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -121,7 +121,7 @@ class SupplierPartList(generics.ListCreateAPIView): search_fields = [ 'SKU', 'supplier__name', - 'manufacturer', + 'manufacturer_name', 'description', 'MPN', ] diff --git a/InvenTree/company/forms.py b/InvenTree/company/forms.py index 0da509a3b5..3b3a99ef59 100644 --- a/InvenTree/company/forms.py +++ b/InvenTree/company/forms.py @@ -53,6 +53,7 @@ class EditSupplierPartForm(HelperForm): 'SKU', 'description', 'manufacturer', + 'manufacturer_name', 'MPN', 'link', 'note', diff --git a/InvenTree/company/migrations/0017_auto_20200413_0320.py b/InvenTree/company/migrations/0017_auto_20200413_0320.py new file mode 100644 index 0000000000..0c13496713 --- /dev/null +++ b/InvenTree/company/migrations/0017_auto_20200413_0320.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-04-13 03:20 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0016_auto_20200412_2330'), + ] + + operations = [ + migrations.RenameField( + model_name='supplierpart', + old_name='manufacturer', + new_name='manufacturer_name', + ), + ] diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index f99c855c77..75d52893a4 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -224,7 +224,7 @@ class SupplierPart(models.Model): part: Link to the master Part supplier: Company that supplies this SupplierPart object SKU: Stock keeping unit (supplier part number) - manufacturer: Manufacturer name + manufacturer: Company that manufactures the SupplierPart (leave blank if it is the sample as the Supplier!) MPN: Manufacture part number link: Link to external website for this part description: Descriptive notes field @@ -261,7 +261,14 @@ class SupplierPart(models.Model): SKU = models.CharField(max_length=100, help_text=_('Supplier stock keeping unit')) - manufacturer = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer')) + manufacturer = models.ForeignKey(Company, on_delete=models.SET_NULL, + related_name='manufactured_parts', + limit_choices_to={'is_manufacturer': True}, + help_text=_('Select manufacturer'), + null=True, blank=True, + ) + + manufacturer_name = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer')) MPN = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer part number')) diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index 218201179e..6dbafeeea5 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -90,6 +90,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer): 'supplier_logo', 'SKU', 'manufacturer', + 'manufacturer_name', 'description', 'MPN', 'link',