from django.db import models
from django_dag.models import *
from django_dag import models as dag
Relationship=dag.edge_factory('parts.Part') #must specify appname (in this case: 'parts')
class Part(dag.node_factory(Relationship)):
part_no = models.CharField(max_length=30, unique=True, db_index=True)
description = models.TextField(null=True, blank=True)
date_modified = models.DateTimeField(auto_now=True, auto_now_add=False, null=True, blank=True,)
def __unicode__(self):
return u'%s' % (self.part_no)
class Meta:
ordering = ['-date_modified']
class BillOfMaterial(models.Model):
assembly = models.ForeignKey(Part, related_name='bom_assembly', db_index=False)
subpart = models.ForeignKey(Part, related_name='bom_subpart', db_index=False)
item = models.IntegerField(max_length=10, null=True, blank=True)
qty = models.DecimalField(max_digits=10, decimal_places=5)
order = models.IntegerField(max_length=10, null=True, blank=True)
depth = models.IntegerField(max_length=10, null=True, blank=True)
def __unicode__(self):
return u'A:%s P:%s' % (self.assembly_no, self.subpart_no)
Comments