mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Improved admin view for part
This commit is contained in:
parent
5420f83114
commit
492c651324
@ -61,7 +61,7 @@ class InvenTreeTree(models.Model):
|
|||||||
return acceptable
|
return acceptable
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def parentpath(self):
|
||||||
""" Return the parent path of this category
|
""" Return the parent path of this category
|
||||||
|
|
||||||
Todo:
|
Todo:
|
||||||
@ -70,11 +70,16 @@ class InvenTreeTree(models.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self.parent:
|
if self.parent:
|
||||||
return self.parent.path + [self.parent]
|
return self.parent.parentpath + [self.parent]
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return parent_path
|
@property
|
||||||
|
def path(self):
|
||||||
|
if self.parent:
|
||||||
|
return "/".join([p.name for p in self.parentpath]) + "/" + self.name
|
||||||
|
else:
|
||||||
|
return self.name
|
||||||
|
|
||||||
def __setattr__(self, attrname, val):
|
def __setattr__(self, attrname, val):
|
||||||
""" Custom Attribute Setting function
|
""" Custom Attribute Setting function
|
||||||
@ -118,10 +123,7 @@ class InvenTreeTree(models.Model):
|
|||||||
This is recursive - Make it not so.
|
This is recursive - Make it not so.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.parent:
|
return self.path
|
||||||
return "/".join([p.name for p in self.path]) + "/" + self.name
|
|
||||||
else:
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -2,12 +2,14 @@ from django.contrib import admin
|
|||||||
|
|
||||||
from .models import PartCategory, Part
|
from .models import PartCategory, Part
|
||||||
|
|
||||||
admin.site.register(Part)
|
class PartAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('name', 'IPN', 'category')
|
||||||
|
|
||||||
# Custom form for PartCategory
|
# Custom form for PartCategory
|
||||||
class PartCategoryAdmin(admin.ModelAdmin):
|
class PartCategoryAdmin(admin.ModelAdmin):
|
||||||
# TODO - Only let valid parents be displayed
|
|
||||||
pass
|
list_display = ('name', 'path')
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(Part, PartAdmin)
|
||||||
admin.site.register(PartCategory, PartCategoryAdmin)
|
admin.site.register(PartCategory, PartCategoryAdmin)
|
@ -20,6 +20,8 @@ class Part(models.Model):
|
|||||||
description = models.CharField(max_length=250, blank=True)
|
description = models.CharField(max_length=250, blank=True)
|
||||||
IPN = models.CharField(max_length=100, blank=True)
|
IPN = models.CharField(max_length=100, blank=True)
|
||||||
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
|
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
|
||||||
|
minimum_stock = models.IntegerField(default=0)
|
||||||
|
units = models.CharField(max_length=20, default="pcs", blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.IPN:
|
if self.IPN:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user