mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Supplier app
- Supplier - SupplierPart - SupplierPartBreak
This commit is contained in:
parent
726e8dce48
commit
8e3672f3a1
@ -39,7 +39,8 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'part.apps.PartConfig',
|
||||
'stock.apps.StockConfig'
|
||||
'stock.apps.StockConfig',
|
||||
'supplier.apps.SupplierConfig'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -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),
|
||||
]
|
||||
|
0
InvenTree/supplier/__init__.py
Normal file
0
InvenTree/supplier/__init__.py
Normal file
6
InvenTree/supplier/admin.py
Normal file
6
InvenTree/supplier/admin.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Supplier, SupplierPart
|
||||
|
||||
admin.site.register(Supplier)
|
||||
admin.site.register(SupplierPart)
|
7
InvenTree/supplier/apps.py
Normal file
7
InvenTree/supplier/apps.py
Normal file
@ -0,0 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SupplierConfig(AppConfig):
|
||||
name = 'supplier'
|
53
InvenTree/supplier/models.py
Normal file
53
InvenTree/supplier/models.py
Normal 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)
|
3
InvenTree/supplier/tests.py
Normal file
3
InvenTree/supplier/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
InvenTree/supplier/urls.py
Normal file
7
InvenTree/supplier/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index')
|
||||
]
|
5
InvenTree/supplier/views.py
Normal file
5
InvenTree/supplier/views.py
Normal 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")
|
Loading…
Reference in New Issue
Block a user