mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Moving 'supplier' to 'company'
This commit is contained in:
		@@ -8,37 +8,6 @@ from django.db.models.signals import pre_delete
 | 
				
			|||||||
from django.dispatch import receiver
 | 
					from django.dispatch import receiver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Company(models.Model):
 | 
					 | 
				
			||||||
    """ Abstract model representing an external company
 | 
					 | 
				
			||||||
    """
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    class Meta:
 | 
					 | 
				
			||||||
        abstract = True
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    name = models.CharField(max_length=100, unique=True,
 | 
					 | 
				
			||||||
                            help_text='Company naem')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    description = models.CharField(max_length=500)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    website = models.URLField(blank=True, help_text='Company website URL')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    address = models.CharField(max_length=200,
 | 
					 | 
				
			||||||
                               blank=True, help_text='Company address')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    phone = models.CharField(max_length=50,
 | 
					 | 
				
			||||||
                             blank=True)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    email = models.EmailField(blank=True)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    contact = models.CharField(max_length=100,
 | 
					 | 
				
			||||||
                               blank=True)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    notes = models.TextField(blank=True)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def __str__(self):
 | 
					 | 
				
			||||||
        return self.name
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class InvenTreeTree(models.Model):
 | 
					class InvenTreeTree(models.Model):
 | 
				
			||||||
    """ Provides an abstracted self-referencing tree model for data categories.
 | 
					    """ Provides an abstracted self-referencing tree model for data categories.
 | 
				
			||||||
    - Each Category has one parent Category, which can be blank (for a top-level Category).
 | 
					    - Each Category has one parent Category, which can be blank (for a top-level Category).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ INSTALLED_APPS = [
 | 
				
			|||||||
    # InvenTree apps
 | 
					    # InvenTree apps
 | 
				
			||||||
    'part.apps.PartConfig',
 | 
					    'part.apps.PartConfig',
 | 
				
			||||||
    'stock.apps.StockConfig',
 | 
					    'stock.apps.StockConfig',
 | 
				
			||||||
    'supplier.apps.SupplierConfig',
 | 
					    'company.apps.CompanyConfig',
 | 
				
			||||||
    'build.apps.BuildConfig',
 | 
					    'build.apps.BuildConfig',
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ from stock.urls import stock_api_urls, stock_api_loc_urls
 | 
				
			|||||||
from stock.urls import stock_urls
 | 
					from stock.urls import stock_urls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# from supplier.urls import supplier_api_urls, supplier_api_part_urls
 | 
					# from supplier.urls import supplier_api_urls, supplier_api_part_urls
 | 
				
			||||||
from supplier.urls import supplier_urls
 | 
					from company.urls import company_urls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from build.urls import build_urls
 | 
					from build.urls import build_urls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -68,7 +68,7 @@ urlpatterns = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    url(r'^part/', include(part_urls)),
 | 
					    url(r'^part/', include(part_urls)),
 | 
				
			||||||
    url(r'^stock/', include(stock_urls)),
 | 
					    url(r'^stock/', include(stock_urls)),
 | 
				
			||||||
    url(r'^supplier/', include(supplier_urls)),
 | 
					    url(r'^company/', include(company_urls)),
 | 
				
			||||||
    url(r'^build/', include(build_urls)),
 | 
					    url(r'^build/', include(build_urls)),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'^admin/', admin.site.urls),
 | 
					    url(r'^admin/', admin.site.urls),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,10 @@
 | 
				
			|||||||
from django.contrib import admin
 | 
					from django.contrib import admin
 | 
				
			||||||
from import_export.admin import ImportExportModelAdmin
 | 
					from import_export.admin import ImportExportModelAdmin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import Supplier, SupplierPart, Manufacturer
 | 
					from .models import Company, SupplierPart
 | 
				
			||||||
from .models import SupplierOrder
 | 
					from .models import SupplierOrder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierAdmin(ImportExportModelAdmin):
 | 
					class CompanyAdmin(ImportExportModelAdmin):
 | 
				
			||||||
    list_display = ('name', 'website', 'contact')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ManufacturerAdmin(ImportExportModelAdmin):
 | 
					 | 
				
			||||||
    list_display = ('name', 'website', 'contact')
 | 
					    list_display = ('name', 'website', 'contact')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -20,7 +16,6 @@ class SupplierOrderAdmin(admin.ModelAdmin):
 | 
				
			|||||||
    list_display = ('internal_ref', 'supplier', 'issued_date', 'delivery_date', 'status')
 | 
					    list_display = ('internal_ref', 'supplier', 'issued_date', 'delivery_date', 'status')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
admin.site.register(Supplier, SupplierAdmin)
 | 
					admin.site.register(Company, CompanyAdmin)
 | 
				
			||||||
admin.site.register(Manufacturer, ManufacturerAdmin)
 | 
					 | 
				
			||||||
admin.site.register(SupplierPart, SupplierPartAdmin)
 | 
					admin.site.register(SupplierPart, SupplierPartAdmin)
 | 
				
			||||||
admin.site.register(SupplierOrder, SupplierOrderAdmin)
 | 
					admin.site.register(SupplierOrder, SupplierOrderAdmin)
 | 
				
			||||||
@@ -3,5 +3,5 @@ from __future__ import unicode_literals
 | 
				
			|||||||
from django.apps import AppConfig
 | 
					from django.apps import AppConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierConfig(AppConfig):
 | 
					class CompanyConfig(AppConfig):
 | 
				
			||||||
    name = 'supplier'
 | 
					    name = 'company'
 | 
				
			||||||
@@ -2,7 +2,7 @@ from django import forms
 | 
				
			|||||||
from crispy_forms.helper import FormHelper
 | 
					from crispy_forms.helper import FormHelper
 | 
				
			||||||
from crispy_forms.layout import Submit
 | 
					from crispy_forms.layout import Submit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import Supplier, SupplierPart
 | 
					from .models import Company, SupplierPart
 | 
				
			||||||
from .models import SupplierOrder
 | 
					from .models import SupplierOrder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -28,10 +28,10 @@ class EditSupplierOrderForm(forms.ModelForm):
 | 
				
			|||||||
        ]
 | 
					        ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class EditSupplierForm(forms.ModelForm):
 | 
					class EditCompanyForm(forms.ModelForm):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, *args, **kwargs):
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
        super(EditSupplierForm, self).__init__(*args, **kwargs)
 | 
					        super(EditCompanyForm, self).__init__(*args, **kwargs)
 | 
				
			||||||
        self.helper = FormHelper()
 | 
					        self.helper = FormHelper()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.helper.form_id = 'id-edit-part-form'
 | 
					        self.helper.form_id = 'id-edit-part-form'
 | 
				
			||||||
@@ -41,7 +41,7 @@ class EditSupplierForm(forms.ModelForm):
 | 
				
			|||||||
        self.helper.add_input(Submit('submit', 'Submit'))
 | 
					        self.helper.add_input(Submit('submit', 'Submit'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Supplier
 | 
					        model = Company
 | 
				
			||||||
        fields = [
 | 
					        fields = [
 | 
				
			||||||
            'name',
 | 
					            'name',
 | 
				
			||||||
            'description',
 | 
					            'description',
 | 
				
			||||||
@@ -6,16 +6,37 @@ from django.utils.translation import ugettext as _
 | 
				
			|||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
from django.core.validators import MinValueValidator
 | 
					from django.core.validators import MinValueValidator
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from InvenTree.models import Company
 | 
					 | 
				
			||||||
from part.models import Part
 | 
					from part.models import Part
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Company(models.Model):
 | 
				
			||||||
class Supplier(Company):
 | 
					    """ Abstract model representing an external company
 | 
				
			||||||
    """ Represents a manufacturer or supplier
 | 
					 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    name = models.CharField(max_length=100, unique=True,
 | 
				
			||||||
 | 
					                            help_text='Company naem')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    description = models.CharField(max_length=500)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    website = models.URLField(blank=True, help_text='Company website URL')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    address = models.CharField(max_length=200,
 | 
				
			||||||
 | 
					                               blank=True, help_text='Company address')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    phone = models.CharField(max_length=50,
 | 
				
			||||||
 | 
					                             blank=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    email = models.EmailField(blank=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    contact = models.CharField(max_length=100,
 | 
				
			||||||
 | 
					                               blank=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    notes = models.TextField(blank=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __str__(self):
 | 
				
			||||||
 | 
					        return self.name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_absolute_url(self):
 | 
					    def get_absolute_url(self):
 | 
				
			||||||
        return "/supplier/{id}/".format(id=self.id)
 | 
					        return "/company/{id}/".format(id=self.id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def part_count(self):
 | 
					    def part_count(self):
 | 
				
			||||||
@@ -34,12 +55,6 @@ class Supplier(Company):
 | 
				
			|||||||
        return self.order_count > 0
 | 
					        return self.order_count > 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Manufacturer(Company):
 | 
					 | 
				
			||||||
    """ Represents a manfufacturer
 | 
					 | 
				
			||||||
    """
 | 
					 | 
				
			||||||
    pass
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class SupplierPart(models.Model):
 | 
					class SupplierPart(models.Model):
 | 
				
			||||||
    """ Represents a unique part as provided by a Supplier
 | 
					    """ Represents a unique part as provided by a Supplier
 | 
				
			||||||
    Each SupplierPart is identified by a MPN (Manufacturer Part Number)
 | 
					    Each SupplierPart is identified by a MPN (Manufacturer Part Number)
 | 
				
			||||||
@@ -58,12 +73,12 @@ class SupplierPart(models.Model):
 | 
				
			|||||||
    part = models.ForeignKey(Part, on_delete=models.CASCADE,
 | 
					    part = models.ForeignKey(Part, on_delete=models.CASCADE,
 | 
				
			||||||
                             related_name='supplier_parts')
 | 
					                             related_name='supplier_parts')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE,
 | 
					    supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
 | 
				
			||||||
                                 related_name='parts')
 | 
					                                 related_name='parts')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SKU = models.CharField(max_length=100, help_text='Supplier stock keeping unit')
 | 
					    SKU = models.CharField(max_length=100, help_text='Supplier stock keeping unit')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    manufacturer = models.ForeignKey(Manufacturer, blank=True, null=True, on_delete=models.SET_NULL, help_text='Manufacturer')
 | 
					    manufacturer = models.CharField(max_length=100, blank=True, help_text='Manufacturer')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MPN = models.CharField(max_length=100, blank=True, help_text='Manufacturer part number')
 | 
					    MPN = models.CharField(max_length=100, blank=True, help_text='Manufacturer part number')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -127,7 +142,7 @@ class SupplierOrder(models.Model):
 | 
				
			|||||||
    # Interal reference for this order
 | 
					    # Interal reference for this order
 | 
				
			||||||
    internal_ref = models.CharField(max_length=25, unique=True)
 | 
					    internal_ref = models.CharField(max_length=25, unique=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE,
 | 
					    supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
 | 
				
			||||||
                                 related_name='orders')
 | 
					                                 related_name='orders')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    created_date = models.DateField(auto_now_add=True, editable=False)
 | 
					    created_date = models.DateField(auto_now_add=True, editable=False)
 | 
				
			||||||
@@ -2,29 +2,13 @@ from rest_framework import serializers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from part.models import Part
 | 
					from part.models import Part
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import Supplier, SupplierPart, SupplierPriceBreak
 | 
					from .models import Company, SupplierPart, SupplierPriceBreak
 | 
				
			||||||
from .models import Manufacturer
 | 
					 | 
				
			||||||
from .models import Customer
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierSerializer(serializers.HyperlinkedModelSerializer):
 | 
					class CompanySerializer(serializers.HyperlinkedModelSerializer):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Supplier
 | 
					        model = Company
 | 
				
			||||||
        fields = '__all__'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ManufacturerSerializer(serializers.HyperlinkedModelSerializer):
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    class Meta:
 | 
					 | 
				
			||||||
        model = Manufacturer
 | 
					 | 
				
			||||||
        fields = '__all__'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class CustomerSerializer(serializers.HyperlinkedModelSerializer):
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    class Meta:
 | 
					 | 
				
			||||||
        model = Customer
 | 
					 | 
				
			||||||
        fields = '__all__'
 | 
					        fields = '__all__'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,13 +47,13 @@ supplier_api_urls = [
 | 
				
			|||||||
]
 | 
					]
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
supplier_detail_urls = [
 | 
					company_detail_urls = [
 | 
				
			||||||
    url(r'edit/?', views.SupplierEdit.as_view(), name='supplier-edit'),
 | 
					    url(r'edit/?', views.CompanyEdit.as_view(), name='company-edit'),
 | 
				
			||||||
    url(r'delete/?', views.SupplierDelete.as_view(), name='supplier-delete'),
 | 
					    url(r'delete/?', views.CompanyDelete.as_view(), name='company-delete'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'orders/?', views.SupplierDetail.as_view(template_name='supplier/orders.html'), name='supplier-detail-orders'),
 | 
					    url(r'orders/?', views.CompanyDetail.as_view(template_name='supplier/orders.html'), name='company-detail-orders'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'^.*$', views.SupplierDetail.as_view(), name='supplier-detail'),
 | 
					    url(r'^.*$', views.CompanyDetail.as_view(), name='company-detail'),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
supplier_part_detail_urls = [
 | 
					supplier_part_detail_urls = [
 | 
				
			||||||
@@ -69,6 +69,7 @@ supplier_part_urls = [
 | 
				
			|||||||
    url(r'^(?P<pk>\d+)/', include(supplier_part_detail_urls)),
 | 
					    url(r'^(?P<pk>\d+)/', include(supplier_part_detail_urls)),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
supplier_order_detail_urls = [
 | 
					supplier_order_detail_urls = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -80,20 +81,21 @@ supplier_order_urls = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    url(r'^(?P<pk>\d+)/', include(supplier_order_detail_urls)),
 | 
					    url(r'^(?P<pk>\d+)/', include(supplier_order_detail_urls)),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
supplier_urls = [
 | 
					company_urls = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'part/', include(supplier_part_urls)),
 | 
					    url(r'supplier_part/', include(supplier_part_urls)),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'order/', include(supplier_order_urls)),
 | 
					    #url(r'order/', include(supplier_order_urls)),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'new/?', views.SupplierCreate.as_view(), name='supplier-create'),
 | 
					    #url(r'new/?', views.SupplierCreate.as_view(), name='supplier-create'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'^(?P<pk>\d+)/', include(supplier_detail_urls)),
 | 
					    url(r'^(?P<pk>\d+)/', include(company_detail_urls)),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    url(r'', views.SupplierIndex.as_view(), name='supplier-index'),
 | 
					    url(r'', views.CompanyIndex.as_view(), name='company-index'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Redirect any other patterns
 | 
					    # Redirect any other patterns
 | 
				
			||||||
    url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='supplier-index'),
 | 
					    url(r'^.*$', RedirectView.as_view(url='', permanent=False), name='company-index'),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
@@ -5,17 +5,18 @@ from django.views.generic import DetailView, ListView
 | 
				
			|||||||
from django.views.generic.edit import UpdateView, DeleteView, CreateView
 | 
					from django.views.generic.edit import UpdateView, DeleteView, CreateView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from part.models import Part
 | 
					from part.models import Part
 | 
				
			||||||
from .models import Supplier, SupplierPart
 | 
					from .models import Company
 | 
				
			||||||
 | 
					from .models import SupplierPart
 | 
				
			||||||
from .models import SupplierOrder
 | 
					from .models import SupplierOrder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .forms import EditSupplierForm
 | 
					from .forms import EditCompanyForm
 | 
				
			||||||
from .forms import EditSupplierPartForm
 | 
					from .forms import EditSupplierPartForm
 | 
				
			||||||
from .forms import EditSupplierOrderForm
 | 
					from .forms import EditSupplierOrderForm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierOrderDetail(DetailView):
 | 
					class SupplierOrderDetail(DetailView):
 | 
				
			||||||
    context_object_name = 'order'
 | 
					    context_object_name = 'order'
 | 
				
			||||||
    model = SupplierOrder
 | 
					    model = SupplierOrder
 | 
				
			||||||
    template_name = 'supplier/order_detail.html'
 | 
					    template_name = 'company/order_detail.html'
 | 
				
			||||||
    queryset = SupplierOrder.objects.all()
 | 
					    queryset = SupplierOrder.objects.all()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,7 +24,7 @@ class SupplierOrderCreate(CreateView):
 | 
				
			|||||||
    model = SupplierOrder
 | 
					    model = SupplierOrder
 | 
				
			||||||
    form_class = EditSupplierOrderForm
 | 
					    form_class = EditSupplierOrderForm
 | 
				
			||||||
    context_object_name = 'supplier'
 | 
					    context_object_name = 'supplier'
 | 
				
			||||||
    template_name = 'supplier/order_create.html'
 | 
					    template_name = 'company/order_create.html'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_initial(self):
 | 
					    def get_initial(self):
 | 
				
			||||||
        initials = super(SupplierOrderCreate, self).get_initial().copy()
 | 
					        initials = super(SupplierOrderCreate, self).get_initial().copy()
 | 
				
			||||||
@@ -36,58 +37,58 @@ class SupplierOrderCreate(CreateView):
 | 
				
			|||||||
        return initials
 | 
					        return initials
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierIndex(ListView):
 | 
					class CompanyIndex(ListView):
 | 
				
			||||||
    model = Supplier
 | 
					    model = Company
 | 
				
			||||||
    template_name = 'supplier/index.html'
 | 
					    template_name = 'company/index.html'
 | 
				
			||||||
    context_object_name = 'suppliers'
 | 
					    context_object_name = 'companies'
 | 
				
			||||||
    paginate_by = 50
 | 
					    paginate_by = 50
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_queryset(self):
 | 
					    def get_queryset(self):
 | 
				
			||||||
        return Supplier.objects.order_by('name')
 | 
					        return Supplier.objects.order_by('name')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierDetail(DetailView):
 | 
					class CompanyDetail(DetailView):
 | 
				
			||||||
    context_obect_name = 'supplier'
 | 
					    context_obect_name = 'company'
 | 
				
			||||||
    template_name = 'supplier/detail.html'
 | 
					    template_name = 'company/detail.html'
 | 
				
			||||||
    queryset = Supplier.objects.all()
 | 
					    queryset = Company.objects.all()
 | 
				
			||||||
    model = Supplier
 | 
					    model = Company
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierEdit(UpdateView):
 | 
					class CompanyEdit(UpdateView):
 | 
				
			||||||
    model = Supplier
 | 
					    model = Company
 | 
				
			||||||
    form_class = EditSupplierForm
 | 
					    form_class = EditCompanyForm
 | 
				
			||||||
    template_name = 'supplier/edit.html'
 | 
					    template_name = 'company/edit.html'
 | 
				
			||||||
    context_object_name = 'supplier'
 | 
					    context_object_name = 'supplier'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierCreate(CreateView):
 | 
					class CompanyCreate(CreateView):
 | 
				
			||||||
    model = Supplier
 | 
					    model = Company
 | 
				
			||||||
    form_class = EditSupplierForm
 | 
					    form_class = EditCompanyForm
 | 
				
			||||||
    template_name = "supplier/create.html"
 | 
					    template_name = "company/create.html"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierDelete(DeleteView):
 | 
					class CompanyDelete(DeleteView):
 | 
				
			||||||
    model = Supplier
 | 
					    model = Company
 | 
				
			||||||
    success_url = '/supplier/'
 | 
					    success_url = '/company/'
 | 
				
			||||||
    template_name = 'supplier/delete.html'
 | 
					    template_name = 'company/delete.html'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def post(self, request, *args, **kwargs):
 | 
					    def post(self, request, *args, **kwargs):
 | 
				
			||||||
        if 'confirm' in request.POST:
 | 
					        if 'confirm' in request.POST:
 | 
				
			||||||
            return super(SupplierDelete, self).post(request, *args, **kwargs)
 | 
					            return super(CompanyDelete, self).post(request, *args, **kwargs)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            return HttpResponseRedirect(self.get_object().get_absolute_url())
 | 
					            return HttpResponseRedirect(self.get_object().get_absolute_url())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierPartDetail(DetailView):
 | 
					class SupplierPartDetail(DetailView):
 | 
				
			||||||
    model = SupplierPart
 | 
					    model = SupplierPart
 | 
				
			||||||
    template_name = 'supplier/partdetail.html'
 | 
					    template_name = 'company/partdetail.html'
 | 
				
			||||||
    context_object_name = 'part'
 | 
					    context_object_name = 'part'
 | 
				
			||||||
    queryset = SupplierPart.objects.all()
 | 
					    queryset = SupplierPart.objects.all()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SupplierPartEdit(UpdateView):
 | 
					class SupplierPartEdit(UpdateView):
 | 
				
			||||||
    model = SupplierPart
 | 
					    model = SupplierPart
 | 
				
			||||||
    template_name = 'supplier/partedit.html'
 | 
					    template_name = 'company/partedit.html'
 | 
				
			||||||
    context_object_name = 'part'
 | 
					    context_object_name = 'part'
 | 
				
			||||||
    form_class = EditSupplierPartForm
 | 
					    form_class = EditSupplierPartForm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -95,7 +96,7 @@ class SupplierPartEdit(UpdateView):
 | 
				
			|||||||
class SupplierPartCreate(CreateView):
 | 
					class SupplierPartCreate(CreateView):
 | 
				
			||||||
    model = SupplierPart
 | 
					    model = SupplierPart
 | 
				
			||||||
    form_class = EditSupplierPartForm
 | 
					    form_class = EditSupplierPartForm
 | 
				
			||||||
    template_name = 'supplier/partcreate.html'
 | 
					    template_name = 'company/partcreate.html'
 | 
				
			||||||
    context_object_name = 'part'
 | 
					    context_object_name = 'part'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_initial(self):
 | 
					    def get_initial(self):
 | 
				
			||||||
@@ -119,7 +120,7 @@ class SupplierPartCreate(CreateView):
 | 
				
			|||||||
class SupplierPartDelete(DeleteView):
 | 
					class SupplierPartDelete(DeleteView):
 | 
				
			||||||
    model = SupplierPart
 | 
					    model = SupplierPart
 | 
				
			||||||
    success_url = '/supplier/'
 | 
					    success_url = '/supplier/'
 | 
				
			||||||
    template_name = 'supplier/partdelete.html'
 | 
					    template_name = 'company/partdelete.html'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def post(self, request, *args, **kwargs):
 | 
					    def post(self, request, *args, **kwargs):
 | 
				
			||||||
        if 'confirm' in request.POST:
 | 
					        if 'confirm' in request.POST:
 | 
				
			||||||
@@ -9,7 +9,7 @@ import django.db.models.deletion
 | 
				
			|||||||
class Migration(migrations.Migration):
 | 
					class Migration(migrations.Migration):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dependencies = [
 | 
					    dependencies = [
 | 
				
			||||||
        ('supplier', '0007_auto_20180416_1253'),
 | 
					        ('company', '0007_auto_20180416_1253'),
 | 
				
			||||||
        ('part', '0021_part_default_location'),
 | 
					        ('part', '0021_part_default_location'),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
        migrations.AddField(
 | 
					        migrations.AddField(
 | 
				
			||||||
            model_name='part',
 | 
					            model_name='part',
 | 
				
			||||||
            name='default_supplier',
 | 
					            name='default_supplier',
 | 
				
			||||||
            field=models.ForeignKey(blank=True, help_text='Default supplier part', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_parts', to='supplier.SupplierPart'),
 | 
					            field=models.ForeignKey(blank=True, help_text='Default supplier part', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_parts', to='company.SupplierPart'),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        migrations.AlterField(
 | 
					        migrations.AlterField(
 | 
				
			||||||
            model_name='part',
 | 
					            model_name='part',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,6 @@ from django.db.models.signals import pre_delete
 | 
				
			|||||||
from django.dispatch import receiver
 | 
					from django.dispatch import receiver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from InvenTree.models import InvenTreeTree
 | 
					from InvenTree.models import InvenTreeTree
 | 
				
			||||||
# from stock.models import StockLocation
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PartCategory(InvenTreeTree):
 | 
					class PartCategory(InvenTreeTree):
 | 
				
			||||||
@@ -112,7 +111,7 @@ class Part(models.Model):
 | 
				
			|||||||
                                         related_name='default_parts')
 | 
					                                         related_name='default_parts')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Default supplier part
 | 
					    # Default supplier part
 | 
				
			||||||
    default_supplier = models.ForeignKey('supplier.SupplierPart',
 | 
					    default_supplier = models.ForeignKey('company.SupplierPart',
 | 
				
			||||||
                                         on_delete=models.SET_NULL,
 | 
					                                         on_delete=models.SET_NULL,
 | 
				
			||||||
                                         blank=True, null=True,
 | 
					                                         blank=True, null=True,
 | 
				
			||||||
                                         help_text='Default supplier part',
 | 
					                                         help_text='Default supplier part',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ from django.dispatch import receiver
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from supplier.models import SupplierPart
 | 
					from company.models import SupplierPart
 | 
				
			||||||
from part.models import Part
 | 
					from part.models import Part
 | 
				
			||||||
from InvenTree.models import InvenTreeTree
 | 
					from InvenTree.models import InvenTreeTree
 | 
				
			||||||
from build.models import Build
 | 
					from build.models import Build
 | 
				
			||||||
@@ -81,9 +81,8 @@ class StockItem(models.Model):
 | 
				
			|||||||
                                   related_name='owned_parts', blank=True, null=True,
 | 
					                                   related_name='owned_parts', blank=True, null=True,
 | 
				
			||||||
                                   help_text='Is this item installed in another item?')
 | 
					                                   help_text='Is this item installed in another item?')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # TODO - Point to a Company object instead
 | 
					 | 
				
			||||||
    # The StockItem may be assigned to a particular customer
 | 
					    # The StockItem may be assigned to a particular customer
 | 
				
			||||||
    customer = models.ForeignKey('supplier.Supplier', on_delete=models.SET_NULL,
 | 
					    customer = models.ForeignKey('company.Company', on_delete=models.SET_NULL,
 | 
				
			||||||
                                 related_name='stockitems', blank=True, null=True,
 | 
					                                 related_name='stockitems', blank=True, null=True,
 | 
				
			||||||
                                 help_text='Item assigned to customer?')
 | 
					                                 help_text='Item assigned to customer?')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,6 @@
 | 
				
			|||||||
      <li><a href="{% url 'stock-index' %}">Stock</a></li>
 | 
					      <li><a href="{% url 'stock-index' %}">Stock</a></li>
 | 
				
			||||||
      <li><a href="{% url 'build-index' %}">Build</a></li>
 | 
					      <li><a href="{% url 'build-index' %}">Build</a></li>
 | 
				
			||||||
      <li><a href="{% url 'supplier-index' %}">Suppliers</a></li>
 | 
					      <li><a href="{% url 'supplier-index' %}">Suppliers</a></li>
 | 
				
			||||||
      <li><a href="{% url 'customer-index' %}">Customers</a></li>
 | 
					 | 
				
			||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</nav>
 | 
					</nav>
 | 
				
			||||||
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -17,7 +17,7 @@ test:
 | 
				
			|||||||
migrate:
 | 
					migrate:
 | 
				
			||||||
	python InvenTree/manage.py makemigrations part
 | 
						python InvenTree/manage.py makemigrations part
 | 
				
			||||||
	python InvenTree/manage.py makemigrations stock
 | 
						python InvenTree/manage.py makemigrations stock
 | 
				
			||||||
	python InvenTree/manage.py makemigrations supplier
 | 
						python InvenTree/manage.py makemigrations company
 | 
				
			||||||
	python InvenTree/manage.py makemigrations build
 | 
						python InvenTree/manage.py makemigrations build
 | 
				
			||||||
	python InvenTree/manage.py migrate --run-syncdb
 | 
						python InvenTree/manage.py migrate --run-syncdb
 | 
				
			||||||
	python InvenTree/manage.py check
 | 
						python InvenTree/manage.py check
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user