From 41aceb8076db439732aadb601aea59f02ec5f682 2012-07-31 12:55:14 From: Lance Edgar Date: 2012-07-31 12:55:14 Subject: [PATCH] add Subdepartment class --- diff --git a/rattail/db/extension/model.py b/rattail/db/extension/model.py index 88aed840fd66783d9fb58413eda8d3e1483c8655..2b34feddcbc7ed34b5e619550adb954594deaa63 100644 --- a/rattail/db/extension/model.py +++ b/rattail/db/extension/model.py @@ -42,8 +42,8 @@ from edbob.db.extensions.auth import Person __all__ = ['SilColumn', 'BatchDictionaryColumn', 'BatchDictionary', 'BatchTerminalColumn', 'BatchTerminal', 'BatchColumn', - 'Batch', 'Brand', 'Department', 'Category', 'Product', - 'Employee'] + 'Batch', 'Brand', 'Department', 'Subdepartment', 'Category', + 'Product', 'Employee'] sil_type_pattern = re.compile(r'^(CHAR|NUMBER)\((\d+(?:\,\d+)?)\)$') @@ -528,8 +528,29 @@ class Department(Base): def __repr__(self): return "" % self.name - def __str__(self): - return str(self.name or '') + def __unicode__(self): + return unicode(self.name or '') + + +class Subdepartment(Base): + """ + Represents an organizational subdepartment. + """ + + __tablename__ = 'subdepartments' + + uuid = uuid_column() + number = Column(Integer) + name = Column(String(30)) + department_uuid = Column(String(32), ForeignKey('departments.uuid')) + + department = relationship(Department) + + def __repr__(self): + return "" % self.name + + def __unicode__(self): + return unicode(self.name or '') class Category(Base):