Improve contact name handling for new custorder
This commit is contained in:
parent
c611eb3787
commit
5e339bb7ea
3 changed files with 45 additions and 19 deletions
|
@ -48,7 +48,7 @@ class CustomerOrderBatchView(BatchMasterView):
|
|||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'customer',
|
||||
'contact_name',
|
||||
'rowcount',
|
||||
'total_price',
|
||||
'created',
|
||||
|
@ -98,7 +98,7 @@ class CustomerOrderBatchView(BatchMasterView):
|
|||
|
||||
g.set_type('total_price', 'currency')
|
||||
|
||||
g.set_link('customer')
|
||||
g.set_link('contact_name')
|
||||
g.set_link('created')
|
||||
g.set_link('created_by')
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ class CustomerOrderView(MasterView):
|
|||
'customer_uuid': batch.customer_uuid,
|
||||
'person_uuid': batch.person_uuid,
|
||||
'phone_number': batch.phone_number,
|
||||
'contact_display': self.handler.get_contact_display(batch),
|
||||
'contact_display': batch.contact_name,
|
||||
'email_address': batch.email_address,
|
||||
'contact_phones': self.handler.get_contact_phones(batch),
|
||||
'contact_emails': self.handler.get_contact_emails(batch),
|
||||
|
@ -414,6 +414,8 @@ class CustomerOrderView(MasterView):
|
|||
'add_email_address': bool(batch.get_param('add_email_address')),
|
||||
'contact_profile_url': None,
|
||||
'new_customer_name': None,
|
||||
'new_customer_first_name': None,
|
||||
'new_customer_last_name': None,
|
||||
'new_customer_phone': None,
|
||||
'new_customer_email': None,
|
||||
}
|
||||
|
@ -421,6 +423,8 @@ class CustomerOrderView(MasterView):
|
|||
pending = batch.pending_customer
|
||||
if pending:
|
||||
context.update({
|
||||
'new_customer_first_name': pending.first_name,
|
||||
'new_customer_last_name': pending.last_name,
|
||||
'new_customer_name': pending.display_name,
|
||||
'new_customer_phone': pending.phone_number,
|
||||
'new_customer_email': pending.email_address,
|
||||
|
@ -486,6 +490,7 @@ class CustomerOrderView(MasterView):
|
|||
def update_pending_customer(self, batch, data):
|
||||
model = self.model
|
||||
app = self.get_rattail_app()
|
||||
people = app.get_people_handler()
|
||||
|
||||
# clear out any contact it may have
|
||||
self.handler.unassign_contact(batch)
|
||||
|
@ -499,11 +504,15 @@ class CustomerOrderView(MasterView):
|
|||
batch.pending_customer = pending
|
||||
|
||||
# update pending customer info
|
||||
pending.display_name = data['display_name']
|
||||
pending.first_name = data['first_name']
|
||||
pending.last_name = data['last_name']
|
||||
pending.display_name = people.normalize_full_name(pending.first_name,
|
||||
pending.last_name)
|
||||
pending.phone_number = app.format_phone_number(data['phone_number'])
|
||||
pending.email_address = data['email_address']
|
||||
|
||||
# also update the batch w/ contact info
|
||||
batch.contact_name = pending.display_name
|
||||
batch.phone_number = pending.phone_number
|
||||
batch.email_address = pending.email_address
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue