Changeset 2f408c1 in rattail


Ignore:
Timestamp:
03/08/19 14:33:01 (6 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
de18e41
Parents:
6ca0e9c
Message:

Add ProductVolatile model, for "volatile" product attributes

at least that's the idea...hopefully this table "wins the war" for this concept

Location:
rattail
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • rattail/db/model/__init__.py

    r6ca0e9c r2f408c1  
    4545from .products import (Brand, Tax, Product, ProductImage, ProductCode,
    4646                       ProductCost, ProductFutureCost, ProductPrice,
    47                        ProductInventory, ProductStoreInfo, InventoryAdjustmentReason)
     47                       ProductInventory, ProductStoreInfo, ProductVolatile,
     48                       InventoryAdjustmentReason)
    4849from .purchase import (PurchaseBase, PurchaseItemBase, PurchaseCreditBase,
    4950                       Purchase, PurchaseItem, PurchaseCredit)
  • rattail/db/model/products.py

    r6ca0e9c r2f408c1  
    846846
    847847
     848class ProductVolatile(Base):
     849    """
     850    This is the place to find "volatile" data for a given product, or at least
     851    it should be...  As of this writing there are a couple other places to look
     852    but hopefully this table can eventually be "the" place.
     853
     854    Whether any given value in a given record, applies to the "current" app
     855    node only, or if it applies to all nodes, is up to app logic.
     856
     857    Note that a custom app should (most likely) *not* bother "extending" this
     858    table, but rather should create a separate table with similar pattern.
     859    """
     860    __tablename__ = 'product_volatile'
     861    __table_args__ = (
     862        sa.ForeignKeyConstraint(['product_uuid'], ['product.uuid'], name='product_volatile_fk_product'),
     863    )
     864
     865    uuid = uuid_column()
     866
     867    product_uuid = sa.Column(sa.String(length=32), nullable=False)
     868    product = orm.relationship(
     869        Product,
     870        doc="""
     871        Product to which this "volatile" data record pertains.
     872        """,
     873        backref=orm.backref(
     874            'volatile',
     875            uselist=False,
     876            cascade='all, delete-orphan',
     877            doc="""
     878            "Volatile" data record for the product, if any.
     879            """))
     880
     881    true_cost = sa.Column(sa.Numeric(precision=9, scale=5), nullable=True, doc="""
     882    "True" unit cost for the item, if known.  This might include certain
     883    "allowances" (discounts) currently in effect etc.; really anything which
     884    might not be reflected in "official" unit cost for the product.  Usually,
     885    this value is quite easily calculated and so this field serves as more of
     886    a cache, for sake of SQL access to the values.
     887    """)
     888
     889    true_margin = sa.Column(sa.Numeric(precision=8, scale=5), nullable=True, doc="""
     890    "True" profit margin for the "regular" unit price vs. the "true" unit cost
     891    (:attr:`true_cost`).
     892    """)
     893
     894
    848895@six.python_2_unicode_compatible
    849896class InventoryAdjustmentReason(Base):
  • rattail/importing/model.py

    r6ca0e9c r2f408c1  
    22432243
    22442244
     2245class ProductVolatileImporter(ToRattail):
     2246    """
     2247    Data importer for :class:`~rattail.db.model.products.ProductVolatile`.
     2248    """
     2249    model_class = model.ProductVolatile
     2250
     2251
    22452252class LabelProfileImporter(ToRattail):
    22462253    """
  • rattail/importing/rattail.py

    r6ca0e9c r2f408c1  
    113113        importers['ProductPrice'] = ProductPriceImporter
    114114        importers['ProductStoreInfo'] = ProductStoreInfoImporter
     115        importers['ProductVolatile'] = ProductVolatileImporter
    115116        importers['ProductImage'] = ProductImageImporter
    116117        importers['LabelProfile'] = LabelProfileImporter
     
    365366    pass
    366367
     368class ProductVolatileImporter(FromRattail, model.ProductVolatileImporter):
     369    pass
     370
    367371
    368372class ProductImageImporter(FromRattail, model.ProductImageImporter):
Note: See TracChangeset for help on using the changeset viewer.