Changeset 9299cd4 in pycorepos


Ignore:
Timestamp:
08/10/2020 03:57:32 PM (2 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
472f438
Parents:
ef1a25f
Message:

Add "origin" models for office_op schema

File:
1 edited

Legend:

Unmodified
Added
Removed
  • corepos/db/office_op/model.py

    ref1a25f r9299cd4  
    311311
    312312
     313class OriginCountry(Base):
     314    """
     315    Represents a country which relates to the "origin" for some product(s).
     316    """
     317    __tablename__ = 'originCountry'
     318
     319    id = sa.Column('countryID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
     320
     321    name = sa.Column(sa.String(length=50), nullable=True)
     322
     323    abbreviation = sa.Column('abbr', sa.String(length=5), nullable=True)
     324
     325    def __str__(self):
     326        return self.name or self.abbreviation or ""
     327
     328
     329class OriginStateProv(Base):
     330    """
     331    Represents a state/province which relates to the "origin" for some product(s).
     332    """
     333    __tablename__ = 'originStateProv'
     334
     335    id = sa.Column('stateProvID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
     336
     337    name = sa.Column(sa.String(length=50), nullable=True)
     338
     339    abbreviation = sa.Column('abbr', sa.String(length=5), nullable=True)
     340
     341    def __str__(self):
     342        return self.name or self.abbreviation or ""
     343
     344
     345class OriginCustomRegion(Base):
     346    """
     347    Represents a custom region which relates to the "origin" for some product(s).
     348    """
     349    __tablename__ = 'originCustomRegion'
     350
     351    id = sa.Column('customID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
     352
     353    name = sa.Column(sa.String(length=50), nullable=True)
     354
     355    def __str__(self):
     356        return self.name or ""
     357
     358
     359class Origin(Base):
     360    """
     361    Represents a location which is the "origin" for some product(s).
     362    """
     363    __tablename__ = 'origins'
     364    __table_args__ = (
     365        sa.ForeignKeyConstraint(['countryID'], ['originCountry.countryID']),
     366        sa.ForeignKeyConstraint(['stateProvID'], ['originStateProv.stateProvID']),
     367        sa.ForeignKeyConstraint(['customID'], ['originCustomRegion.customID']),
     368    )
     369
     370    id = sa.Column('originID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False)
     371
     372    country_id = sa.Column('countryID', sa.Integer(), nullable=True)
     373    country = orm.relationship(OriginCountry)
     374
     375    state_prov_id = sa.Column('stateProvID', sa.Integer(), nullable=True)
     376    state_prov = orm.relationship(OriginStateProv)
     377
     378    custom_id = sa.Column('customID', sa.Integer(), nullable=True)
     379    custom_region = orm.relationship(OriginCustomRegion)
     380
     381    local = sa.Column(sa.Boolean(), nullable=True, default=0)
     382
     383    name = sa.Column(sa.String(length=100), nullable=True)
     384
     385    short_name = sa.Column('shortName', sa.String(length=50), nullable=True)
     386
     387    def __str__(self):
     388        return self.name or self.short_name or ""
     389
     390
    313391class Product(Base):
    314392    """
Note: See TracChangeset for help on using the changeset viewer.