Changeset - d9051322361d
[Not reviewed]
0 2 0
Lance Edgar (lance) - 3 years ago 2021-09-21 13:47:47
lance@edbob.org
Some tweaks for customer orders

- improve how case size is determined
- auto-delete items when order is deleted
2 files changed with 14 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rattail/batch/custorder.py
Show inline comments
 
@@ -50,7 +50,12 @@ class CustomerOrderBatchHandler(BatchHandler):
 
    has_custom_product_autocomplete = False
 

	
 
    def get_case_size_for_product(self, product):
 
        return product.case_size
 
        if product.case_size:
 
            return product.case_size
 

	
 
        cost = product.cost
 
        if cost:
 
            return cost.case_size
 

	
 
    def custom_product_autocomplete(self, session, term, **kwargs):
 
        """
rattail/db/model/custorders.py
Show inline comments
 
@@ -136,10 +136,14 @@ class CustomerOrder(CustomerOrderBase, Base):
 

	
 
    status_code = sa.Column(sa.Integer(), nullable=False)
 

	
 
    items = orm.relationship('CustomerOrderItem', back_populates='order',
 
                             collection_class=ordering_list('sequence', count_from=1), doc="""
 
    Sequence of :class:`CustomerOrderItem` instances which belong to the order.
 
    """)
 
    items = orm.relationship(
 
        'CustomerOrderItem',
 
        back_populates='order',
 
        collection_class=ordering_list('sequence', count_from=1),
 
        cascade='all, delete-orphan',
 
        doc="""
 
        Sequence of :class:`CustomerOrderItem` instances which belong to the order.
 
        """)
 

	
 
    def __str__(self):
 
        if self.id:
0 comments (0 inline, 0 general)