Changeset - 6626b1479830
[Not reviewed]
0 2 1
Lance Edgar (lance) - 3 years ago 2021-10-07 11:32:11
lance@edbob.org
Add `contact_name` for custorder and batch

so that we have something handy to easily sort/filter by etc.
3 files changed with 52 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/batch/custorder.py
Show inline comments
 
@@ -116,6 +116,9 @@ class CustomerOrderBatchHandler(BatchHandler):
 
        batch.customer = customer
 
        batch.person = person
 

	
 
        # cache contact name
 
        batch.contact_name = self.get_contact_display(batch)
 

	
 
        # update phone/email per new contact
 
        batch.phone_number = None
 
        batch.email_address = None
 
@@ -159,8 +162,13 @@ class CustomerOrderBatchHandler(BatchHandler):
 
        i.e. customer name.
 
        """
 
        contact = self.get_contact(batch)
 
        if contact:
 
            return six.text_type(contact)
 

	
 
        pending = batch.pending_customer
 
        if pending:
 
            return six.text_type(pending)
 

	
 
    def get_contact_phones(self, batch):
 
        """
 
        Retrieve all phone records on file for the batch contact, to
 
@@ -245,6 +253,7 @@ class CustomerOrderBatchHandler(BatchHandler):
 
        """
 
        batch.customer = None
 
        batch.person = None
 
        batch.contact_name = None
 
        batch.phone_number = None
 
        batch.email_address = None
 

	
rattail/db/alembic/versions/c10adeff4117_add_custorder_contact_name.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8; -*-
 
"""add custorder.contact_name
 

	
 
Revision ID: c10adeff4117
 
Revises: 5a256a77e6d0
 
Create Date: 2021-10-07 11:05:10.561894
 

	
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
# revision identifiers, used by Alembic.
 
revision = 'c10adeff4117'
 
down_revision = u'5a256a77e6d0'
 
branch_labels = None
 
depends_on = None
 

	
 
from alembic import op
 
import sqlalchemy as sa
 
import rattail.db.types
 

	
 

	
 

	
 
def upgrade():
 

	
 
    # batch_custorder
 
    op.add_column('batch_custorder', sa.Column('contact_name', sa.String(length=100), nullable=True))
 

	
 
    # custorder
 
    op.add_column('custorder', sa.Column('contact_name', sa.String(length=100), nullable=True))
 

	
 

	
 
def downgrade():
 
    
 
    # custorder
 
    op.drop_column('custorder', 'contact_name')
 
    
 
    # batch_custorder
 
    op.drop_column('batch_custorder', 'contact_name')
rattail/db/model/custorders.py
Show inline comments
 
@@ -103,6 +103,10 @@ class CustomerOrderBase(object):
 
            if applicable.
 
            """)
 

	
 
    contact_name = sa.Column(sa.String(length=100), nullable=True, doc="""
 
    Cached display name for the contact (customer).
 
    """)
 

	
 
    phone_number = sa.Column(sa.String(length=20), nullable=True, doc="""
 
    Customer contact phone number for sake of this order.
 
    """)
0 comments (0 inline, 0 general)