Supplier app

- Supplier
- SupplierPart
- SupplierPartBreak
This commit is contained in:
Oliver Walters 2017-03-27 21:46:58 +11:00
parent 726e8dce48
commit 8e3672f3a1
9 changed files with 84 additions and 1 deletions

View File

@ -39,7 +39,8 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'part.apps.PartConfig',
'stock.apps.StockConfig'
'stock.apps.StockConfig',
'supplier.apps.SupplierConfig'
]
MIDDLEWARE = [

View File

@ -21,5 +21,6 @@ admin.site.site_header = "InvenTree Admin"
urlpatterns = [
url(r'^stock/', include('stock.urls')),
url(r'^part/', include('part.urls')),
url(r'^supplier/', include('supplier.urls')),
url(r'^admin/', admin.site.urls),
]

View File

View File

@ -0,0 +1,6 @@
from django.contrib import admin
from .models import Supplier, SupplierPart
admin.site.register(Supplier)
admin.site.register(SupplierPart)

View File

@ -0,0 +1,7 @@
from __future__ import unicode_literals
from django.apps import AppConfig
class SupplierConfig(AppConfig):
name = 'supplier'

View File

@ -0,0 +1,53 @@
from __future__ import unicode_literals
from django.db import models
from part.models import Part
class Supplier(models.Model):
name = models.CharField(max_length=100)
URL = models.URLField(blank=True)
address = models.CharField(max_length=200,
blank=True)
phone = models.CharField(max_length=50,
blank=True)
email = models.EmailField(blank=True)
contact = models.CharField(max_length=100,
blank=True)
notes = models.CharField(max_length=500,
blank=True)
def __str__(self):
return self.name
class SupplierPart(models.Model):
supplier = models.ForeignKey(Supplier,
on_delete=models.CASCADE)
part = models.ForeignKey(Part,
on_delete=models.CASCADE)
MPN = models.CharField(max_length=100)
URL = models.URLField(blank=True)
description = models.CharField(max_length=250,
blank=True)
def __str__(self):
return "{mpn} - {supplier}".format(
mpn = self.MPN,
supplier = self.supplier.name)
class SupplierPriceBreak(models.Model):
part = models.ForeignKey(SupplierPart,
on_delete=models.CASCADE)
quantity = models.IntegerField()
cost = models.DecimalField(max_digits=10, decimal_places=3)
currency = models.CharField(max_length=10,
blank=True)
def __str__(self):
return "{mpn} - {cost}{currency} @ {quan}".format(
mpn = part.MPN,
cost = self.cost,
currency = self.currency if self.currency else '',
quan = self.quantity)

View File

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

View File

@ -0,0 +1,7 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index')
]

View File

@ -0,0 +1,5 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
def index(request):
return HttpResponse("This is the suppliers page")