Cleanup views for CORE departments a bit
esp. show link to tax rate
This commit is contained in:
parent
076860bfcd
commit
cfb416578c
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -39,6 +39,7 @@ class DepartmentView(CoreOfficeMasterView):
|
|||
route_prefix = 'corepos.departments'
|
||||
|
||||
labels = {
|
||||
'tax_rate_id': "Tax Rate ID",
|
||||
'see_id': "See ID",
|
||||
'modified_by_id': "Modified by ID",
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ class DepartmentView(CoreOfficeMasterView):
|
|||
grid_columns = [
|
||||
'number',
|
||||
'name',
|
||||
'tax',
|
||||
'tax_rate',
|
||||
'food_stampable',
|
||||
'limit',
|
||||
'minimum',
|
||||
|
@ -60,11 +61,16 @@ class DepartmentView(CoreOfficeMasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(DepartmentView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
|
||||
# number
|
||||
g.set_link('number')
|
||||
g.set_sort_defaults('number')
|
||||
g.filters['number'].default_active = True
|
||||
g.filters['number'].default_verb = 'equal'
|
||||
|
||||
# name
|
||||
g.set_link('name')
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
|
||||
|
@ -72,15 +78,37 @@ class DepartmentView(CoreOfficeMasterView):
|
|||
g.set_label('food_stampable', "FS")
|
||||
g.filters['food_stampable'].label = "Food Stampable"
|
||||
|
||||
# currency fields
|
||||
g.set_type('limit', 'currency')
|
||||
g.set_type('minimum', 'currency')
|
||||
|
||||
# modified
|
||||
g.set_type('modified', 'datetime_local')
|
||||
|
||||
g.set_sort_defaults('number')
|
||||
# margin
|
||||
g.set_renderer('margin', self.render_margin)
|
||||
|
||||
g.set_link('number')
|
||||
g.set_link('name')
|
||||
def render_margin(self, dept, field):
|
||||
margin = getattr(dept, field)
|
||||
if margin is None:
|
||||
return
|
||||
app = self.get_rattail_app()
|
||||
return app.render_percent(100 * margin)
|
||||
|
||||
def configure_form(self, f):
|
||||
super(DepartmentView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
|
||||
# tax_rate
|
||||
f.set_renderer('tax_rate', self.render_corepos_tax_rate)
|
||||
|
||||
# currency fields
|
||||
f.set_type('limit', 'currency')
|
||||
f.set_type('minimum', 'currency')
|
||||
|
||||
# margin
|
||||
f.set_renderer('margin', self.render_margin)
|
||||
|
||||
# modified
|
||||
f.set_type('modified', 'datetime_local')
|
||||
|
||||
def core_office_object_url(self, office_url, department):
|
||||
|
|
|
@ -89,6 +89,14 @@ class CoreMasterView(MasterView):
|
|||
number=department_number)
|
||||
return tags.link_to(text, url)
|
||||
|
||||
def render_corepos_tax_rate(self, obj, field):
|
||||
taxrate = getattr(obj, field)
|
||||
if not taxrate:
|
||||
return
|
||||
text = str(taxrate)
|
||||
url = self.request.route_url('corepos.taxrates.view', id=taxrate.id)
|
||||
return tags.link_to(text, url)
|
||||
|
||||
def render_corepos_vendor(self, obj, field):
|
||||
vendor = getattr(obj, field)
|
||||
if not vendor:
|
||||
|
|
Loading…
Reference in a new issue