mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +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)
|
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
|
||||||
minimum_stock = models.IntegerField(default=0)
|
minimum_stock = models.IntegerField(default=0)
|
||||||
units = models.CharField(max_length=20, default="pcs", blank=True)
|
units = models.CharField(max_length=20, default="pcs", blank=True)
|
||||||
|
trackable = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.IPN:
|
if self.IPN:
|
||||||
@ -35,4 +36,18 @@ class Part(models.Model):
|
|||||||
verbose_name = "Part"
|
verbose_name = "Part"
|
||||||
verbose_name_plural = "Parts"
|
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
|
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.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from part.models import Part
|
from part.models import Part, PartRevision
|
||||||
|
|
||||||
class UniquePart(models.Model):
|
class UniquePart(models.Model):
|
||||||
""" A unique instance of a Part object.
|
""" A unique instance of a Part object.
|
||||||
@ -12,12 +12,21 @@ class UniquePart(models.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
part = models.ForeignKey(Part, on_delete=models.CASCADE)
|
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)
|
editable=False)
|
||||||
serial = models.IntegerField()
|
serial = models.IntegerField()
|
||||||
|
|
||||||
createdBy = models.ForeignKey(User)
|
createdBy = models.ForeignKey(User)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.part.name
|
||||||
|
|
||||||
class PartTrackingInfo(models.Model):
|
class PartTrackingInfo(models.Model):
|
||||||
""" Single data-point in the life of a UniquePart
|
""" Single data-point in the life of a UniquePart
|
||||||
Each time something happens to the UniquePart,
|
Each time something happens to the UniquePart,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user