Expose default address for customers view
This commit is contained in:
parent
6da013bf6c
commit
b793998814
|
@ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import six
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ class CustomersView(MasterView):
|
||||||
'id': "ID",
|
'id': "ID",
|
||||||
'default_phone': "Phone Number",
|
'default_phone': "Phone Number",
|
||||||
'default_email': "Email Address",
|
'default_email': "Email Address",
|
||||||
|
'default_address': "Physical Address",
|
||||||
'active_in_pos': "Active in POS",
|
'active_in_pos': "Active in POS",
|
||||||
'active_in_pos_sticky': "Always Active in POS",
|
'active_in_pos_sticky': "Always Active in POS",
|
||||||
}
|
}
|
||||||
|
@ -71,6 +73,7 @@ class CustomersView(MasterView):
|
||||||
'name',
|
'name',
|
||||||
'default_phone',
|
'default_phone',
|
||||||
'default_email',
|
'default_email',
|
||||||
|
'default_address',
|
||||||
'email_preference',
|
'email_preference',
|
||||||
'active_in_pos',
|
'active_in_pos',
|
||||||
'active_in_pos_sticky',
|
'active_in_pos_sticky',
|
||||||
|
@ -157,6 +160,9 @@ class CustomersView(MasterView):
|
||||||
if not self.creating and customer.phones:
|
if not self.creating and customer.phones:
|
||||||
f.set_default('default_phone', customer.phones[0].number)
|
f.set_default('default_phone', customer.phones[0].number)
|
||||||
|
|
||||||
|
f.set_renderer('default_address', self.render_default_address)
|
||||||
|
f.set_readonly('default_address')
|
||||||
|
|
||||||
f.set_enum('email_preference', self.enum.EMAIL_PREFERENCE)
|
f.set_enum('email_preference', self.enum.EMAIL_PREFERENCE)
|
||||||
preferences = list(self.enum.EMAIL_PREFERENCE.items())
|
preferences = list(self.enum.EMAIL_PREFERENCE.items())
|
||||||
preferences.insert(0, ('', "(no preference)"))
|
preferences.insert(0, ('', "(no preference)"))
|
||||||
|
@ -205,6 +211,10 @@ class CustomersView(MasterView):
|
||||||
if customer.phones:
|
if customer.phones:
|
||||||
return customer.phones[0].number
|
return customer.phones[0].number
|
||||||
|
|
||||||
|
def render_default_address(self, customer, field):
|
||||||
|
if customer.addresses:
|
||||||
|
return six.text_type(customer.addresses[0])
|
||||||
|
|
||||||
def render_people(self, customer, field):
|
def render_people(self, customer, field):
|
||||||
people = customer.people
|
people = customer.people
|
||||||
if not people:
|
if not people:
|
||||||
|
|
Loading…
Reference in a new issue