Add setting to expose/hide "active in POS" customer flag

This commit is contained in:
Lance Edgar 2022-07-23 22:06:18 -05:00
parent e77ca93d80
commit 28238c6fb5
2 changed files with 51 additions and 4 deletions

View file

@ -0,0 +1,23 @@
## -*- coding: utf-8; -*-
<%inherit file="/configure.mako" />
<%def name="form_content()">
<h3 class="block is-size-3">POS</h3>
<div class="block" style="padding-left: 2rem;">
<b-field>
<b-checkbox name="rattail.customers.active_in_pos"
v-model="simpleSettings['rattail.customers.active_in_pos']"
native-value="true"
@input="settingsNeedSaved = true">
Expose/track the "Active in POS" flag for customers.
</b-checkbox>
</b-field>
</div>
</%def>
${parent.body()}

View file

@ -50,6 +50,7 @@ class CustomerView(MasterView):
people_detachable = True
touchable = True
supports_autocomplete = True
configurable = True
# whether to show "view full profile" helper for customer view
show_profiles_helper = True
@ -92,6 +93,13 @@ class CustomerView(MasterView):
'members',
]
def get_expose_active_in_pos(self):
if not hasattr(self, '_expose_active_in_pos'):
self._expose_active_in_pos = self.rattail_config.getbool(
'rattail', 'customers.active_in_pos',
default=False)
return self._expose_active_in_pos
def configure_grid(self, g):
super(CustomerView, self).configure_grid(g)
@ -132,8 +140,9 @@ class CustomerView(MasterView):
g.set_renderer('person', self.grid_render_person)
# active_in_pos
g.filters['active_in_pos'].default_active = True
g.filters['active_in_pos'].default_verb = 'is_true'
if self.get_expose_active_in_pos():
g.filters['active_in_pos'].default_active = True
g.filters['active_in_pos'].default_verb = 'is_true'
g.set_link('id')
g.set_link('number')
@ -142,8 +151,9 @@ class CustomerView(MasterView):
g.set_link('email')
def grid_extra_class(self, customer, i):
if not customer.active_in_pos:
return 'warning'
if self.get_expose_active_in_pos():
if not customer.active_in_pos:
return 'warning'
def get_instance(self):
try:
@ -246,6 +256,10 @@ class CustomerView(MasterView):
customer = f.model_instance
permission_prefix = self.get_permission_prefix()
if not self.get_expose_active_in_pos():
f.remove('active_in_pos',
'active_in_pos_sticky')
# members
if self.creating:
f.remove_field('members')
@ -430,6 +444,16 @@ class CustomerView(MasterView):
return self.redirect(self.request.get_referrer())
def configure_get_simple_settings(self):
return [
# POS
{'section': 'rattail',
'option': 'customers.active_in_pos',
'type': bool},
]
@classmethod
def defaults(cls, config):
cls._defaults(config)