Changeset - 4a96ccca75fb
[Not reviewed]
0 1 0
Lance Edgar (lance) - 12 years ago 2012-08-20 11:18:36
lance@edbob.org
add Product.cost, Product.vendor
1 file changed with 21 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/db/extension/model.py
Show inline comments
 
@@ -805,12 +805,13 @@ class Product(Base):
 
    # pack_price = Column(Numeric(8,3))
 

	
 
    department = relationship(Department)
 
    subdepartment = relationship(Subdepartment)
 
    category = relationship(Category)
 
    brand = relationship(Brand)
 

	
 
    costs = relationship(ProductCost, backref='product',
 
                         collection_class=ordering_list('preference', count_from=1),
 
                         order_by=ProductCost.preference)
 

	
 
    def __repr__(self):
 
        return "<Product: %s>" % self.description
 
@@ -831,12 +832,32 @@ Product.regular_price = relationship(
 
Product.current_price = relationship(
 
    ProductPrice,
 
    primaryjoin=Product.current_price_uuid == ProductPrice.uuid,
 
    lazy='joined',
 
    post_update=True)
 

	
 
Product.cost = relationship(
 
    ProductCost,
 
    primaryjoin=and_(
 
        ProductCost.product_uuid == Product.uuid,
 
        ProductCost.preference == 1,
 
        ),
 
    uselist=False,
 
    viewonly=True)
 

	
 
Product.vendor = relationship(
 
    Vendor,
 
    secondary=ProductCost.__table__,
 
    primaryjoin=and_(
 
        ProductCost.product_uuid == Product.uuid,
 
        ProductCost.preference == 1,
 
        ),
 
    secondaryjoin=Vendor.uuid == ProductCost.vendor_uuid,
 
    uselist=False,
 
    viewonly=True)
 

	
 

	
 
class EmployeeEmailAddress(EmailAddress):
 
    """
 
    Represents an email address associated with a :class:`Employee`.
 
    """
 

	
0 comments (0 inline, 0 general)