mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added PartRevision model
- Added 'trackable' field to Part
This commit is contained in:
parent
6aa9f14b46
commit
be030991a5
@ -22,6 +22,7 @@ class Part(models.Model):
|
||||
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
|
||||
minimum_stock = models.IntegerField(default=0)
|
||||
units = models.CharField(max_length=20, default="pcs", blank=True)
|
||||
trackable = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
if self.IPN:
|
||||
@ -35,4 +36,18 @@ class Part(models.Model):
|
||||
verbose_name = "Part"
|
||||
verbose_name_plural = "Parts"
|
||||
|
||||
|
||||
class PartRevision(models.Model):
|
||||
""" A PartRevision represents a change-notification to a Part
|
||||
A Part may go through several revisions in its lifetime,
|
||||
which should be tracked.
|
||||
UniqueParts can have a single associated PartRevision
|
||||
"""
|
||||
|
||||
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
description = models.CharField(max_length=500)
|
||||
revision_date = models.DateField(auto_now_add = True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
@ -2,4 +2,7 @@ from django.contrib import admin
|
||||
|
||||
from .models import UniquePart
|
||||
|
||||
admin.site.register(UniquePart)
|
||||
class UniquePartAdmin(admin.ModelAdmin):
|
||||
list_display = ('part', 'revision', 'serial', 'creation_date')
|
||||
|
||||
admin.site.register(UniquePart, UniquePartAdmin)
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from part.models import Part
|
||||
from part.models import Part, PartRevision
|
||||
|
||||
class UniquePart(models.Model):
|
||||
""" A unique instance of a Part object.
|
||||
@ -12,11 +12,20 @@ class UniquePart(models.Model):
|
||||
"""
|
||||
|
||||
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
||||
created = models.DateField(auto_now_add=True,
|
||||
|
||||
revision = models.ForeignKey(PartRevision,
|
||||
on_delete=models.CASCADE,
|
||||
blank=True,
|
||||
null=True)
|
||||
|
||||
creation_date = models.DateField(auto_now_add=True,
|
||||
editable=False)
|
||||
serial = models.IntegerField()
|
||||
|
||||
createdBy = models.ForeignKey(User)
|
||||
|
||||
def __str__(self):
|
||||
return self.part.name
|
||||
|
||||
class PartTrackingInfo(models.Model):
|
||||
""" Single data-point in the life of a UniquePart
|
||||
|
Loading…
Reference in New Issue
Block a user