diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 8590375..12688af 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -169,6 +169,25 @@ class Store(Base): return self.description or "" +class MasterSuperDepartment(Base): + """ + A department may belong to more than one superdepartment, but has + one "master" superdepartment. This avoids duplicating rows in + some reports. By convention, a department's "master" + superdepartment is the one with the lowest superID. + """ + __tablename__ = 'MasterSuperDepts' + + super_id = sa.Column('superID', sa.Integer(), primary_key=True, autoincrement=False, nullable=False) + + department_id = sa.Column('dept_ID', sa.Integer(), primary_key=True, autoincrement=False, nullable=False) + + super_name = sa.Column(sa.String(length=50), nullable=True) + + def __str__(self): + return self.super_name or "" + + class SuperDepartment(Base): """ Represents a "super" (parent/child) department mapping.