Include member type column for legacy customers grid
This commit is contained in:
parent
b5036eb094
commit
92f6226ad6
|
@ -28,6 +28,8 @@ from corepos.db.office_op import model as corepos
|
||||||
|
|
||||||
from rattail_corepos.config import core_office_customer_account_url
|
from rattail_corepos.config import core_office_customer_account_url
|
||||||
|
|
||||||
|
from webhelpers2.html import tags
|
||||||
|
|
||||||
from .master import CoreOfficeMasterView
|
from .master import CoreOfficeMasterView
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
'card_number',
|
'card_number',
|
||||||
'first_name',
|
'first_name',
|
||||||
'last_name',
|
'last_name',
|
||||||
|
'member_type',
|
||||||
'charge_ok',
|
'charge_ok',
|
||||||
'charge_limit',
|
'charge_limit',
|
||||||
'balance',
|
'balance',
|
||||||
|
@ -70,6 +73,10 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
g.filters['last_name'].default_active = True
|
g.filters['last_name'].default_active = True
|
||||||
g.filters['last_name'].default_verb = 'contains'
|
g.filters['last_name'].default_verb = 'contains'
|
||||||
|
|
||||||
|
g.set_joiner('member_type', lambda q: q.outerjoin(corepos.MemberType))
|
||||||
|
g.set_sorter('member_type', corepos.MemberType.description)
|
||||||
|
g.set_filter('member_type', corepos.MemberType.description)
|
||||||
|
|
||||||
g.set_type('charge_limit', 'currency')
|
g.set_type('charge_limit', 'currency')
|
||||||
g.set_type('balance', 'currency')
|
g.set_type('balance', 'currency')
|
||||||
g.set_type('purchases', 'currency')
|
g.set_type('purchases', 'currency')
|
||||||
|
@ -83,6 +90,9 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(CustomerView, self).configure_form(f)
|
super(CustomerView, self).configure_form(f)
|
||||||
|
|
||||||
|
# member_type
|
||||||
|
f.set_renderer('member_type', self.render_member_type)
|
||||||
|
|
||||||
if self.creating or self.editing:
|
if self.creating or self.editing:
|
||||||
f.remove_field('member_info')
|
f.remove_field('member_info')
|
||||||
f.remove_field('member_type')
|
f.remove_field('member_type')
|
||||||
|
@ -90,6 +100,14 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
else:
|
else:
|
||||||
f.set_type('last_change', 'datetime_local')
|
f.set_type('last_change', 'datetime_local')
|
||||||
|
|
||||||
|
def render_member_type(self, custdata, field):
|
||||||
|
memtype = custdata.member_type
|
||||||
|
if not memtype:
|
||||||
|
return
|
||||||
|
text = str(memtype)
|
||||||
|
url = self.request.route_url('corepos.member_types.view', id=memtype.id)
|
||||||
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
def core_office_object_url(self, office_url, customer):
|
def core_office_object_url(self, office_url, customer):
|
||||||
return core_office_customer_account_url(self.rattail_config,
|
return core_office_customer_account_url(self.rattail_config,
|
||||||
customer.card_number,
|
customer.card_number,
|
||||||
|
|
Loading…
Reference in a new issue