Added 'track' app

- Keeping track of UniquePart objects
This commit is contained in:
Oliver Walters 2017-03-27 22:32:34 +11:00
parent af679a1ac6
commit f17e9de37b
8 changed files with 54 additions and 1 deletions

View File

@ -40,7 +40,8 @@ INSTALLED_APPS = [
'part.apps.PartConfig',
'stock.apps.StockConfig',
'supplier.apps.SupplierConfig'
'supplier.apps.SupplierConfig',
'track.apps.TrackConfig'
]
MIDDLEWARE = [

View File

@ -13,6 +13,7 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
@ -22,5 +23,6 @@ urlpatterns = [
url(r'^stock/', include('stock.urls')),
url(r'^part/', include('part.urls')),
url(r'^supplier/', include('supplier.urls')),
url(r'^track/', include('track.urls')),
url(r'^admin/', admin.site.urls),
]

View File

5
InvenTree/track/admin.py Normal file
View File

@ -0,0 +1,5 @@
from django.contrib import admin
from .models import UniquePart
admin.site.register(UniquePart)

7
InvenTree/track/apps.py Normal file
View File

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

32
InvenTree/track/models.py Normal file
View File

@ -0,0 +1,32 @@
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
from part.models import Part
class UniquePart(models.Model):
""" A unique instance of a Part object.
Used for tracking parts based on serial numbers,
and tracking all events in the life of a part
"""
part = models.ForeignKey(Part, on_delete=models.CASCADE)
created = models.DateField(auto_now_add=True,
editable=False)
serial = models.IntegerField()
createdBy = models.ForeignKey(User)
class PartTrackingInfo(models.Model):
""" Single data-point in the life of a UniquePart
Each time something happens to the UniquePart,
a new PartTrackingInfo object should be created.
"""
part = models.ForeignKey(UniquePart, on_delete=models.CASCADE)
date = models.DateField(auto_now_add=True,
editable=False)
notes = models.CharField(max_length=500)

3
InvenTree/track/tests.py Normal file
View File

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

3
InvenTree/track/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.