mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-03 09:00:57 +00:00
Moving 'supplier' to 'company'
This commit is contained in:
1 parent
3bb434ae98
commit
cef3c664f9
50 files changed
+95
-132
No files matched your search
@@ -8,37 +8,6 @@ from django.db.models.signals import pre_delete
|
||||
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):
|
||||
""" 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).
|
||||
|
||||
@@ -49,7 +49,7 @@ INSTALLED_APPS = [
|
||||
# InvenTree apps
|
||||
'part.apps.PartConfig',
|
||||
'stock.apps.StockConfig',
|
||||
'supplier.apps.SupplierConfig',
|
||||
'company.apps.CompanyConfig',
|
||||
'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 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
|
||||
|
||||
@@ -68,7 +68,7 @@ urlpatterns = [
|
||||
|
||||
url(r'^part/', include(part_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'^admin/', admin.site.urls),
|
||||
|
||||
File renamed without changes.
@@ -1,14 +1,10 @@
|
||||
from django.contrib import admin
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
|
||||
from .models import Supplier, SupplierPart, Manufacturer
|
||||
from .models import Company, SupplierPart
|
||||
from .models import SupplierOrder
|
||||
|
||||
class SupplierAdmin(ImportExportModelAdmin):
|
||||
list_display = ('name', 'website', 'contact')
|
||||
|
||||
|
||||
class ManufacturerAdmin(ImportExportModelAdmin):
|
||||
class CompanyAdmin(ImportExportModelAdmin):
|
||||
list_display = ('name', 'website', 'contact')
|
||||
|
||||
|
||||
@@ -20,7 +16,6 @@ class SupplierOrderAdmin(admin.ModelAdmin):
|
||||
list_display = ('internal_ref', 'supplier', 'issued_date', 'delivery_date', 'status')
|
||||
|
||||
|
||||
admin.site.register(Supplier, SupplierAdmin)
|
||||
admin.site.register(Manufacturer, ManufacturerAdmin)
|
||||
admin.site.register(Company, CompanyAdmin)
|
||||
admin.site.register(SupplierPart, SupplierPartAdmin)
|
||||
admin.site.register(SupplierOrder, SupplierOrderAdmin)
|
||||
File renamed without changes.
@@ -3,5 +3,5 @@ from __future__ import unicode_literals
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SupplierConfig(AppConfig):
|
||||
name = 'supplier'
|
||||
class CompanyConfig(AppConfig):
|
||||
name = 'company'
|
||||
@@ -2,7 +2,7 @@ from django import forms
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Submit
|
||||
|
||||
from .models import Supplier, SupplierPart
|
||||
from .models import Company, SupplierPart
|
||||
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):
|
||||
super(EditSupplierForm, self).__init__(*args, **kwargs)
|
||||
super(EditCompanyForm, self).__init__(*args, **kwargs)
|
||||
self.helper = FormHelper()
|
||||
|
||||
self.helper.form_id = 'id-edit-part-form'
|
||||
@@ -41,7 +41,7 @@ class EditSupplierForm(forms.ModelForm):
|
||||
self.helper.add_input(Submit('submit', 'Submit'))
|
||||
|
||||
class Meta:
|
||||
model = Supplier
|
||||
model = Company
|
||||
fields = [
|
||||
'name',
|
||||
'description',
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,16 +6,37 @@ from django.utils.translation import ugettext as _
|
||||
from django.db import models
|
||||
from django.core.validators import MinValueValidator
|
||||
|
||||
from InvenTree.models import Company
|
||||
from part.models import Part
|
||||
|
||||
|
||||
class Supplier(Company):
|
||||
""" Represents a manufacturer or supplier
|
||||
class Company(models.Model):
|
||||
""" Abstract model representing an external company
|
||||
"""
|
||||
|
||||
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):
|
||||
return "/supplier/{id}/".format(id=self.id)
|
||||
return "/company/{id}/".format(id=self.id)
|
||||
|
||||
@property
|
||||
def part_count(self):
|
||||
@@ -34,12 +55,6 @@ class Supplier(Company):
|
||||
return self.order_count > 0
|
||||
|
||||
|
||||
class Manufacturer(Company):
|
||||
""" Represents a manfufacturer
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class SupplierPart(models.Model):
|
||||
""" Represents a unique part as provided by a Supplier
|
||||
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,
|
||||
related_name='supplier_parts')
|
||||
|
||||
supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE,
|
||||
supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
|
||||
related_name='parts')
|
||||
|
||||
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')
|
||||
|
||||
@@ -127,7 +142,7 @@ class SupplierOrder(models.Model):
|
||||
# Interal reference for this order
|
||||
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')
|
||||
|
||||
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 .models import Supplier, SupplierPart, SupplierPriceBreak
|
||||
from .models import Manufacturer
|
||||
from .models import Customer
|
||||
from .models import Company, SupplierPart, SupplierPriceBreak
|
||||
|
||||
|
||||
class SupplierSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class CompanySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Supplier
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ManufacturerSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Manufacturer
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CustomerSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Customer
|
||||
model = Company
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -47,13 +47,13 @@ supplier_api_urls = [
|
||||
]
|
||||
"""
|
||||
|
||||
supplier_detail_urls = [
|
||||
url(r'edit/?', views.SupplierEdit.as_view(), name='supplier-edit'),
|
||||
url(r'delete/?', views.SupplierDelete.as_view(), name='supplier-delete'),
|
||||
company_detail_urls = [
|
||||
url(r'edit/?', views.CompanyEdit.as_view(), name='company-edit'),
|
||||
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 = [
|
||||
@@ -69,6 +69,7 @@ supplier_part_urls = [
|
||||
url(r'^(?P<pk>\d+)/', include(supplier_part_detail_urls)),
|
||||
]
|
||||
|
||||
"""
|
||||
supplier_order_detail_urls = [
|
||||
|
||||
|
||||
@@ -80,20 +81,21 @@ supplier_order_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
|
||||
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 part.models import Part
|
||||
from .models import Supplier, SupplierPart
|
||||
from .models import Company
|
||||
from .models import SupplierPart
|
||||
from .models import SupplierOrder
|
||||
|
||||
from .forms import EditSupplierForm
|
||||
from .forms import EditCompanyForm
|
||||
from .forms import EditSupplierPartForm
|
||||
from .forms import EditSupplierOrderForm
|
||||
|
||||
class SupplierOrderDetail(DetailView):
|
||||
context_object_name = 'order'
|
||||
model = SupplierOrder
|
||||
template_name = 'supplier/order_detail.html'
|
||||
template_name = 'company/order_detail.html'
|
||||
queryset = SupplierOrder.objects.all()
|
||||
|
||||
|
||||
@@ -23,7 +24,7 @@ class SupplierOrderCreate(CreateView):
|
||||
model = SupplierOrder
|
||||
form_class = EditSupplierOrderForm
|
||||
context_object_name = 'supplier'
|
||||
template_name = 'supplier/order_create.html'
|
||||
template_name = 'company/order_create.html'
|
||||
|
||||
def get_initial(self):
|
||||
initials = super(SupplierOrderCreate, self).get_initial().copy()
|
||||
@@ -36,58 +37,58 @@ class SupplierOrderCreate(CreateView):
|
||||
return initials
|
||||
|
||||
|
||||
class SupplierIndex(ListView):
|
||||
model = Supplier
|
||||
template_name = 'supplier/index.html'
|
||||
context_object_name = 'suppliers'
|
||||
class CompanyIndex(ListView):
|
||||
model = Company
|
||||
template_name = 'company/index.html'
|
||||
context_object_name = 'companies'
|
||||
paginate_by = 50
|
||||
|
||||
def get_queryset(self):
|
||||
return Supplier.objects.order_by('name')
|
||||
|
||||
|
||||
class SupplierDetail(DetailView):
|
||||
context_obect_name = 'supplier'
|
||||
template_name = 'supplier/detail.html'
|
||||
queryset = Supplier.objects.all()
|
||||
model = Supplier
|
||||
class CompanyDetail(DetailView):
|
||||
context_obect_name = 'company'
|
||||
template_name = 'company/detail.html'
|
||||
queryset = Company.objects.all()
|
||||
model = Company
|
||||
|
||||
|
||||
class SupplierEdit(UpdateView):
|
||||
model = Supplier
|
||||
form_class = EditSupplierForm
|
||||
template_name = 'supplier/edit.html'
|
||||
class CompanyEdit(UpdateView):
|
||||
model = Company
|
||||
form_class = EditCompanyForm
|
||||
template_name = 'company/edit.html'
|
||||
context_object_name = 'supplier'
|
||||
|
||||
|
||||
class SupplierCreate(CreateView):
|
||||
model = Supplier
|
||||
form_class = EditSupplierForm
|
||||
template_name = "supplier/create.html"
|
||||
class CompanyCreate(CreateView):
|
||||
model = Company
|
||||
form_class = EditCompanyForm
|
||||
template_name = "company/create.html"
|
||||
|
||||
|
||||
class SupplierDelete(DeleteView):
|
||||
model = Supplier
|
||||
success_url = '/supplier/'
|
||||
template_name = 'supplier/delete.html'
|
||||
class CompanyDelete(DeleteView):
|
||||
model = Company
|
||||
success_url = '/company/'
|
||||
template_name = 'company/delete.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'confirm' in request.POST:
|
||||
return super(SupplierDelete, self).post(request, *args, **kwargs)
|
||||
return super(CompanyDelete, self).post(request, *args, **kwargs)
|
||||
else:
|
||||
return HttpResponseRedirect(self.get_object().get_absolute_url())
|
||||
|
||||
|
||||
class SupplierPartDetail(DetailView):
|
||||
model = SupplierPart
|
||||
template_name = 'supplier/partdetail.html'
|
||||
template_name = 'company/partdetail.html'
|
||||
context_object_name = 'part'
|
||||
queryset = SupplierPart.objects.all()
|
||||
|
||||
|
||||
class SupplierPartEdit(UpdateView):
|
||||
model = SupplierPart
|
||||
template_name = 'supplier/partedit.html'
|
||||
template_name = 'company/partedit.html'
|
||||
context_object_name = 'part'
|
||||
form_class = EditSupplierPartForm
|
||||
|
||||
@@ -95,7 +96,7 @@ class SupplierPartEdit(UpdateView):
|
||||
class SupplierPartCreate(CreateView):
|
||||
model = SupplierPart
|
||||
form_class = EditSupplierPartForm
|
||||
template_name = 'supplier/partcreate.html'
|
||||
template_name = 'company/partcreate.html'
|
||||
context_object_name = 'part'
|
||||
|
||||
def get_initial(self):
|
||||
@@ -119,7 +120,7 @@ class SupplierPartCreate(CreateView):
|
||||
class SupplierPartDelete(DeleteView):
|
||||
model = SupplierPart
|
||||
success_url = '/supplier/'
|
||||
template_name = 'supplier/partdelete.html'
|
||||
template_name = 'company/partdelete.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'confirm' in request.POST:
|
||||
@@ -9,7 +9,7 @@ import django.db.models.deletion
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('supplier', '0007_auto_20180416_1253'),
|
||||
('company', '0007_auto_20180416_1253'),
|
||||
('part', '0021_part_default_location'),
|
||||
]
|
||||
|
||||
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='part',
|
||||
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(
|
||||
model_name='part',
|
||||
|
||||
@@ -11,7 +11,6 @@ from django.db.models.signals import pre_delete
|
||||
from django.dispatch import receiver
|
||||
|
||||
from InvenTree.models import InvenTreeTree
|
||||
# from stock.models import StockLocation
|
||||
|
||||
|
||||
class PartCategory(InvenTreeTree):
|
||||
@@ -112,7 +111,7 @@ class Part(models.Model):
|
||||
related_name='default_parts')
|
||||
|
||||
# Default supplier part
|
||||
default_supplier = models.ForeignKey('supplier.SupplierPart',
|
||||
default_supplier = models.ForeignKey('company.SupplierPart',
|
||||
on_delete=models.SET_NULL,
|
||||
blank=True, null=True,
|
||||
help_text='Default supplier part',
|
||||
|
||||
@@ -11,7 +11,7 @@ from django.dispatch import receiver
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from supplier.models import SupplierPart
|
||||
from company.models import SupplierPart
|
||||
from part.models import Part
|
||||
from InvenTree.models import InvenTreeTree
|
||||
from build.models import Build
|
||||
@@ -81,9 +81,8 @@ class StockItem(models.Model):
|
||||
related_name='owned_parts', blank=True, null=True,
|
||||
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
|
||||
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,
|
||||
help_text='Item assigned to customer?')
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<li><a href="{% url 'stock-index' %}">Stock</a></li>
|
||||
<li><a href="{% url 'build-index' %}">Build</a></li>
|
||||
<li><a href="{% url 'supplier-index' %}">Suppliers</a></li>
|
||||
<li><a href="{% url 'customer-index' %}">Customers</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -17,7 +17,7 @@ test:
|
||||
migrate:
|
||||
python InvenTree/manage.py makemigrations part
|
||||
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 migrate --run-syncdb
|
||||
python InvenTree/manage.py check
|
||||
|
||||
Reference in new issue
Block a user