Changeset 2045661 in rattail


Ignore:
Timestamp:
07/03/18 20:46:45 (2 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
f985d83
Parents:
b11ff75
Message:

Add Product.default_pack, plus is_unit_item() and is_pack_item()

Location:
rattail/db
Files:
1 added
1 edited

Legend:

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

    rb11ff75 r2045661  
    224224    """)
    225225
     226    default_pack = sa.Column(sa.Boolean(), nullable=True, doc="""
     227    If set, this flag indicates the product is the "default pack" for its unit
     228    item.  This flag is only relevant if the product is in fact a pack item; it
     229    should be effectively ignored for a unit item.
     230    """)
     231
    226232    case_size = sa.Column(sa.Numeric(precision=9, scale=4), nullable=True, doc="""
    227233    Case size for the product, i.e. how many units (current product) are
     
    379385        return make_full_description(self.brand.name if self.brand else '',
    380386                                     self.description, self.size)
     387
     388    def is_unit_item(self):
     389        """
     390        Returns True if the product is considered a "unit" item, as opposed to
     391        a "pack" item.
     392        """
     393        if self.unit:
     394            # we appear to be a pack for some other unit item
     395            return False
     396        return True
     397
     398    def is_pack_item(self):
     399        """
     400        Returns True if the product is considered a "pack" item, as opposed to
     401        a "unit" item.
     402        """
     403        if self.unit:
     404            return True
     405        return False
    381406
    382407    @property
Note: See TracChangeset for help on using the changeset viewer.