Changeset 4abe9d2 in rattail for rattail/db/model/batch/purchase.py


Ignore:
Timestamp:
08/07/18 15:18:06 (22 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
670af56
Parents:
fbddbf5
Message:

Add PurchaseBatchRowClaim.is_empty() convenience method

also we now delete orphan records if "claiming row" is deleted

File:
1 edited

Legend:

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

    rfbddbf5 r4abe9d2  
    240240        backref=orm.backref(
    241241            'claims',
    242             # cascade='all, delete-orphan',
     242            cascade='all, delete-orphan',
    243243            doc="""
    244244            List of claims made by "child" rows against this truck dump batch row.
     
    268268    Number of units of product which were shipped expired, and are involved in the claim.
    269269    """)
     270
     271    def is_empty(self):
     272        """
     273        Returns boolean indicating whether the claim is "empty" - i.e. if it
     274        has zero or null for all of its quantity fields.
     275        """
     276        if self.cases_received:
     277            return False
     278        if self.units_received:
     279            return False
     280
     281        if self.cases_damaged:
     282            return False
     283        if self.units_damaged:
     284            return False
     285
     286        if self.cases_expired:
     287            return False
     288        if self.units_expired:
     289            return False
     290
     291        return True
    270292
    271293
Note: See TracChangeset for help on using the changeset viewer.