Removed 'customer' app

This commit is contained in:
Oliver 2018-04-19 08:25:32 +10:00
parent f1357cfb7c
commit 433f670e1c
25 changed files with 5 additions and 493 deletions

View File

@ -51,7 +51,6 @@ INSTALLED_APPS = [
'stock.apps.StockConfig',
'supplier.apps.SupplierConfig',
'build.apps.BuildConfig',
'customer.apps.CustomerConfig'
]
MIDDLEWARE = [

View File

@ -13,8 +13,6 @@ from supplier.urls import supplier_urls
from build.urls import build_urls
from customer.urls import customer_urls
from django.conf import settings
from django.conf.urls.static import static
@ -47,7 +45,6 @@ apipatterns = [
# url(r'^supplier-part/', include(supplier_api_part_urls)),
# url(r'^price-break/', include(price_break_urls)),
# url(r'^manufacturer/', include(manu_urls)),
# url(r'^customer/', include(cust_urls)),
# Tracking URLs
# url(r'^track/', include(part_track_urls)),
@ -73,7 +70,6 @@ urlpatterns = [
url(r'^stock/', include(stock_urls)),
url(r'^supplier/', include(supplier_urls)),
url(r'^build/', include(build_urls)),
url(r'^customer/', include(customer_urls)),
url(r'^admin/', admin.site.urls),
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),

View File

@ -1,21 +0,0 @@
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from .models import Customer, CustomerOrder, CustomerOrderLine
class CustomerAdmin(ImportExportModelAdmin):
list_display = ('name', 'website', 'contact')
class CustomerOrderAdmin(admin.ModelAdmin):
list_display = ('internal_ref',)
class CustomerOrderLineAdmin(admin.ModelAdmin):
list_display = ('customer_order', 'line_number')
admin.site.register(Customer, CustomerAdmin)
admin.site.register(CustomerOrder, CustomerOrderAdmin)
admin.site.register(CustomerOrderLine, CustomerOrderLineAdmin)

View File

@ -1,5 +0,0 @@
from django.apps import AppConfig
class CustomerConfig(AppConfig):
name = 'customer'

View File

@ -1,62 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-17 13:37
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('part', '0022_auto_20180417_0819'),
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
('description', models.CharField(max_length=500)),
('website', models.URLField(blank=True)),
('address', models.CharField(blank=True, max_length=200)),
('phone', models.CharField(blank=True, max_length=50)),
('email', models.EmailField(blank=True, max_length=254)),
('contact', models.CharField(blank=True, max_length=100)),
('notes', models.CharField(blank=True, max_length=500)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='CustomerOrder',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('internal_ref', models.CharField(max_length=100, unique=True)),
('customer_ref', models.CharField(blank=True, default=b'', max_length=100)),
('created_date', models.DateField(auto_now_add=True, help_text=b'Date order entered in system')),
('issued_date', models.DateField(blank=True, help_text=b'Date order issued by customer')),
('notes', models.TextField(blank=True, default=b'', help_text=b'Order notes')),
('customer', models.ForeignKey(blank=True, help_text=b'Customer that placed this order', null=True, on_delete=django.db.models.deletion.SET_NULL, to='customer.Customer')),
],
),
migrations.CreateModel(
name='CustomerOrderLine',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('line_number', models.PositiveIntegerField(default=0, help_text=b'Line number')),
('quantity', models.PositiveIntegerField(blank=True, help_text=b'Quantity of part')),
('notes', models.TextField(blank=True, help_text=b'Line notes')),
('customer_order', models.ForeignKey(help_text=b'Order this line belongs to', on_delete=django.db.models.deletion.CASCADE, to='customer.CustomerOrder')),
('part', models.ForeignKey(blank=True, help_text=b'Part', on_delete=django.db.models.deletion.CASCADE, to='part.Part')),
],
),
migrations.AlterUniqueTogether(
name='customerorderline',
unique_together=set([('customer_order', 'line_number')]),
),
]

View File

@ -1,35 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-17 14:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('customer', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='customer',
name='address',
field=models.CharField(blank=True, help_text='Company address', max_length=200),
),
migrations.AlterField(
model_name='customer',
name='name',
field=models.CharField(help_text='Company naem', max_length=100, unique=True),
),
migrations.AlterField(
model_name='customer',
name='notes',
field=models.TextField(blank=True),
),
migrations.AlterField(
model_name='customer',
name='website',
field=models.URLField(blank=True, help_text='Company website URL'),
),
]

View File

@ -1,66 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-17 14:28
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('customer', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='customerorder',
name='created_date',
field=models.DateField(auto_now_add=True, help_text='Date order entered in system'),
),
migrations.AlterField(
model_name='customerorder',
name='customer',
field=models.ForeignKey(blank=True, help_text='Customer that placed this order', null=True, on_delete=django.db.models.deletion.SET_NULL, to='customer.Customer'),
),
migrations.AlterField(
model_name='customerorder',
name='customer_ref',
field=models.CharField(blank=True, default='', max_length=100),
),
migrations.AlterField(
model_name='customerorder',
name='issued_date',
field=models.DateField(blank=True, help_text='Date order issued by customer'),
),
migrations.AlterField(
model_name='customerorder',
name='notes',
field=models.TextField(blank=True, default='', help_text='Order notes'),
),
migrations.AlterField(
model_name='customerorderline',
name='customer_order',
field=models.ForeignKey(help_text='Order this line belongs to', on_delete=django.db.models.deletion.CASCADE, to='customer.CustomerOrder'),
),
migrations.AlterField(
model_name='customerorderline',
name='line_number',
field=models.PositiveIntegerField(default=0, help_text='Line number'),
),
migrations.AlterField(
model_name='customerorderline',
name='notes',
field=models.TextField(blank=True, help_text='Line notes'),
),
migrations.AlterField(
model_name='customerorderline',
name='part',
field=models.ForeignKey(blank=True, help_text='Part', on_delete=django.db.models.deletion.CASCADE, related_name='order_lines', to='part.Part'),
),
migrations.AlterField(
model_name='customerorderline',
name='quantity',
field=models.PositiveIntegerField(blank=True, help_text='Quantity of part'),
),
]

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-17 15:14
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('customer', '0002_auto_20180418_0028'),
]
operations = [
migrations.AlterField(
model_name='customerorderline',
name='customer_order',
field=models.ForeignKey(help_text=b'Order this line belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='customer.CustomerOrder'),
),
migrations.AlterField(
model_name='customerorderline',
name='part',
field=models.ForeignKey(blank=True, help_text=b'Part', on_delete=django.db.models.deletion.CASCADE, to='part.Part'),
),
]

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-17 15:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('customer', '0003_auto_20180417_1514'),
]
operations = [
migrations.AlterField(
model_name='customer',
name='notes',
field=models.TextField(blank=True),
),
]

View File

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-17 15:17
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('customer', '0002_auto_20180417_1436'),
('customer', '0004_auto_20180417_1516'),
]
operations = [
]

View File

@ -1,75 +0,0 @@
from django.db import models
from InvenTree.models import Company
from part.models import Part
import datetime
class Customer(Company):
""" Represents a customer
"""
pass
class CustomerOrder(models.Model):
"""
An order from a customer, made up of multiple 'lines'
"""
# Reference 'number' internal to company, must be unique
internal_ref = models.CharField(max_length=100, unique=True)
# TODO: Should the Customer model move to the customer_orders app?
# Orders can exist even if the customer doesn't in the database
customer = models.ForeignKey(Customer, on_delete=models.SET_NULL,
blank=True, null=True, help_text="Customer that placed this order")
# Reference from customer, if provided
customer_ref = models.CharField(max_length=100, blank=True, default="")
# TODO: Should the customer and customer_ref together be unique?
# Date the order was entered into system
created_date = models.DateField(auto_now_add=True, blank=True, help_text="Date order entered in system")
# Date the order was issued on the paperwork, if provided
issued_date = models.DateField(blank=True, help_text="Date order issued by customer")
# Order notes
notes = models.TextField(blank=True, default="", help_text="Order notes")
def __str__(self):
return "OrderRef {internal_ref}".format(internal_ref=self.internal_ref)
class CustomerOrderLine(models.Model):
"""
A line on an order from a customer, corresponding to some quantity of some parts (hopefully just one part per line
in a sane world, but maybe not).
The line describes the Part ordered, but something needs to associate the StockItem assigned, possibly that will
be the StockItem itself.
"""
class Meta:
unique_together = [
('customer_order', 'line_number')
]
# Point to a specific customer order
customer_order = models.ForeignKey(CustomerOrder, on_delete=models.CASCADE, help_text="Order this line belongs to",
related_name='lines')
line_number = models.PositiveIntegerField(default=0, help_text="Line number")
# TODO: for now, each line corresponds to some quantity of some part, but in future we might want more flexibility
# Only 'salable' items should be allowed in a CSO
part = models.ForeignKey(Part, blank=True, help_text="Part",
limit_choices_to={'salable': True}
)
# TODO: should quantity field here somehow related to quantity field of related part? Views will handle this, right?
quantity = models.PositiveIntegerField(blank=True, help_text="Quantity of part")
# Line notes
notes = models.TextField(blank=True, help_text="Line notes")

View File

@ -1,5 +0,0 @@
{% extends "base.html" %}
{% block content %}
{% endblock %}

View File

@ -1,18 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
<h3>Customers</h3>
<ul class='list-group'>
{% for customer in customers %}
<li class='list-group-item'>
<b><a href="{% url 'customer-detail' customer.id %}">{{ customer.name }}</a></b>
<br>
{{ customer.description }}
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -1,10 +0,0 @@
{% extends "base.html" %}
{% block content %}
<h4>Order Summary</h4>
{{ order.internal_ref }}
<h4>Order Detail</h4>
{% include "customer/order_lines_table.html" with order_lines=order.lines.all %}
{% endblock %}

View File

@ -1,11 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
{% if customer_orders.all|length > 0 %}
<h4>Customer Orders</h4>
{% include "customer/orders_table.html" with customer_orders=customer_orders %}
{% endif %}
{% endblock %}

View File

@ -1,14 +0,0 @@
<table class="table table-striped">
<tr>
<th>Line Number</th>
<th>Part</th>
<th>Quantity</th>
</tr>
{% for line in order_lines %}
<tr>
<td>{{ line.line_number }}</td>
<td>{{ line.part }}</td>
<td>{{ line.quantity }}</td>
</tr>
{% endfor %}
</table>

View File

@ -1,14 +0,0 @@
<table class="table table-striped">
<tr>
<th>Internal Ref</th>
<th>Customer</th>
<th>Customer Ref</th>
</tr>
{% for order in customer_orders %}
<tr>
<td><a href="{% url 'customer-order-detail' order.internal_ref %}">{{ order.internal_ref }}</a></td>
<td>{{ order.customer }}</td>
<td>{{ order.customer_ref }}</td>
</tr>
{% endfor %}
</table>

View File

@ -1,3 +0,0 @@
# from django.test import TestCase
# Create your tests here.

View File

@ -1,46 +0,0 @@
from django.conf.urls import url, include
from . import views
customer_detail_urls = [
# url(r'^edit/?', views.CustomerEdit.as_view(), name='customer-edit'),
# url(r'^delete/?', views.CustomerDelete.as_view(), name='customer-delete'),
# Everything else
url(r'^.*$', views.CustomerDetail.as_view(), name='customer-detail'),
]
customer_order_detail_urls = [
# url(r'^edit/?', views.CustomerOrderEdit.as_view(), name='customer-order-edit'),
# url(r'^delete/?', views.CustomerOrderDelete.as_view(), name='customer-order-delete'),
# Everything else
url(r'^.*$', views.CustomerOrderDetail.as_view(), name='customer-order-detail'),
]
customer_orders_urls = [
# Details of a specific order
# Details of an individual customer
url(r'^(?P<pk>[0-9]+)/', include(customer_order_detail_urls)),
# Create a new customer order
# url(r'new/?', views.CustomerOrderCreate.as_view(), name='customer-order-create'),
# Everything else
url(r'^.*$', views.CustomerOrderIndex.as_view(), name='customer-order-index'),
]
# URL list for customer orders web interface
customer_urls = [
# Customer orders (CSO)
url(r'^order/', include(customer_orders_urls)),
# Details of an individual customer
url(r'^(?P<pk>[0-9]+)/', include(customer_detail_urls)),
# url(r'new/?', views.CustomerCreate.as_view(), name='customer-create'),
# Top level order list
url(r'^.*$', views.CustomerIndex.as_view(), name='customer-index'),
]

View File

@ -1,35 +0,0 @@
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect
from django.views.generic import DetailView, ListView
from django.views.generic.edit import UpdateView, DeleteView, CreateView
from .models import Customer, CustomerOrder
class CustomerIndex(ListView):
model = Customer
template_name = 'customer/index.html'
context_object_name = 'customers'
def get_queryset(self):
return Customer.objects.order_by('name')
class CustomerOrderIndex(ListView):
model = CustomerOrder
template_name = 'customer/order_index.html'
context_object_name = 'orders'
class CustomerDetail(DetailView):
model = Customer
template_name = 'customer/detail.html'
queryset = Customer.objects.all()
context_object_name = 'customer'
class CustomerOrderDetail(DetailView):
model = CustomerOrder
template_name = 'customer/order_detail.html'
queryset = CustomerOrder.objects.all()
context_object_name = 'order'

View File

@ -52,6 +52,6 @@ class EditStockItemForm(forms.ModelForm):
'batch',
'quantity',
'status',
'customer',
#'customer',
'URL',
]

View File

@ -12,7 +12,6 @@ from django.dispatch import receiver
from datetime import datetime
from supplier.models import SupplierPart
from customer.models import Customer
from part.models import Part
from InvenTree.models import InvenTreeTree
from build.models import Build
@ -82,10 +81,11 @@ 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(Customer, on_delete=models.SET_NULL,
related_name='stockitems', blank=True, null=True,
help_text='Item assigned to customer?')
#customer = models.ForeignKey(Customer, on_delete=models.SET_NULL,
# related_name='stockitems', blank=True, null=True,
# help_text='Item assigned to customer?')
# Optional serial number
serial = models.PositiveIntegerField(blank=True, null=True,

View File

@ -19,7 +19,6 @@ migrate:
python InvenTree/manage.py makemigrations stock
python InvenTree/manage.py makemigrations supplier
python InvenTree/manage.py makemigrations build
python InvenTree/manage.py makemigrations customer
python InvenTree/manage.py migrate --run-syncdb
python InvenTree/manage.py check