mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added "Part"
- Has IPN (internal part number) - Linked to a PartCategory
This commit is contained in:
parent
bb4fc9820f
commit
ffb9132de2
@ -1,5 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .models import PartCategory
|
from .models import PartCategory, Part
|
||||||
|
|
||||||
|
admin.site.register(Part)
|
||||||
admin.site.register(PartCategory)
|
admin.site.register(PartCategory)
|
||||||
|
@ -3,12 +3,26 @@ from __future__ import unicode_literals
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
class PartCategory(models.Model):
|
class PartCategory(models.Model):
|
||||||
name = models.CharField(max_length=128)
|
name = models.CharField(max_length=100)
|
||||||
description = models.CharField(max_length=512)
|
description = models.CharField(max_length=250)
|
||||||
parent = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True)
|
parent = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.parent:
|
if self.parent:
|
||||||
return str(self.parent) + "/" + self.name
|
return str(self.parent) + "/" + self.name
|
||||||
|
else:
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Part(models.Model):
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
description = models.CharField(max_length=250, blank=True)
|
||||||
|
IPN = models.CharField(max_length=100, blank=True)
|
||||||
|
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
if self.IPN:
|
||||||
|
return "{name} ({ipn})".format(
|
||||||
|
ipn = self.IPN,
|
||||||
|
name = self.name)
|
||||||
else:
|
else:
|
||||||
return self.name
|
return self.name
|
Loading…
Reference in New Issue
Block a user