Changeset 4592c96 in rattail for rattail/db/model/batch/purchase.py


Ignore:
Timestamp:
11/21/16 01:03:15 (4 years ago)
Author:
Lance Edgar <ledgar@…>
Branches:
custorders, master
Children:
d96d22a
Parents:
eba0833
Message:

Add support for 'receiving' mode for purchase batches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rattail/db/model/batch/purchase.py

    reba0833 r4592c96  
    3131from sqlalchemy.ext.declarative import declared_attr
    3232
    33 from rattail.db.model import Base, PurchaseBase, Purchase, PurchaseItemBase, BatchMixin, BatchRowMixin
     33from rattail.db.model import (Base, PurchaseBase, PurchaseItemBase,
     34                              Purchase, PurchaseItem,
     35                              BatchMixin, BatchRowMixin)
    3436
    3537
     
    5860        backref=orm.backref(
    5961            'batches',
     62            order_by='PurchaseBatch.id',
    6063            doc="""
    6164            List of batches associated with the purchase.
     
    8184    @declared_attr
    8285    def __table_args__(cls):
    83         return cls.__batchrow_table_args__() + cls.__purchaseitem_table_args__()
     86        return cls.__batchrow_table_args__() + cls.__purchaseitem_table_args__() + (
     87            sa.ForeignKeyConstraint(['item_uuid'], ['purchase_item.uuid'], name='purchase_batch_row_fk_item'),
     88        )
    8489
    8590    STATUS_OK                           = 1
     
    8792    STATUS_COST_NOT_FOUND               = 3
    8893    STATUS_CASE_QUANTITY_UNKNOWN        = 4
     94    STATUS_INCOMPLETE                   = 5
     95    STATUS_ORDERED_RECEIVED_DIFFER      = 6
    8996
    9097    STATUS = {
     
    93100        STATUS_COST_NOT_FOUND           : "product found but not cost",
    94101        STATUS_CASE_QUANTITY_UNKNOWN    : "case quantity not known",
     102        STATUS_INCOMPLETE               : "incomplete",
     103        STATUS_ORDERED_RECEIVED_DIFFER  : "ordered / received differ",
    95104    }
     105
     106    item_uuid = sa.Column(sa.String(length=32), nullable=True)
     107
     108    item = orm.relationship(
     109        PurchaseItem,
     110        doc="""
     111        Reference to the purchase item with which the batch row is associated.
     112        May be null, e.g. in the case of a "new purchase" batch.
     113        """)
Note: See TracChangeset for help on using the changeset viewer.