Improve display of purchase credit data
esp. within a receiving batch row
This commit is contained in:
parent
4a9b528c47
commit
3760c3239f
2 changed files with 76 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2018 Lance Edgar
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -34,9 +34,9 @@ from rattail.time import localtime
|
|||
import colander
|
||||
from deform import widget as dfwidget
|
||||
from pyramid import httpexceptions
|
||||
from webhelpers2.html import tags
|
||||
from webhelpers2.html import tags, HTML
|
||||
|
||||
from tailbone import forms
|
||||
from tailbone import forms, grids
|
||||
from tailbone.views.batch import BatchMasterView
|
||||
|
||||
|
||||
|
@ -646,7 +646,6 @@ class PurchasingBatchView(BatchMasterView):
|
|||
|
||||
# readonly fields
|
||||
f.set_readonly('case_quantity')
|
||||
f.set_readonly('credits')
|
||||
|
||||
# quantity fields
|
||||
f.set_type('case_quantity', 'quantity')
|
||||
|
@ -670,6 +669,10 @@ class PurchasingBatchView(BatchMasterView):
|
|||
# upc
|
||||
f.set_type('upc', 'gpc')
|
||||
|
||||
# credits
|
||||
f.set_readonly('credits')
|
||||
f.set_renderer('credits', self.render_row_credits)
|
||||
|
||||
if self.creating:
|
||||
f.remove_fields(
|
||||
'upc',
|
||||
|
@ -704,6 +707,29 @@ class PurchasingBatchView(BatchMasterView):
|
|||
else:
|
||||
f.remove_field('product')
|
||||
|
||||
def render_row_credits(self, row, field):
|
||||
if not row.credits:
|
||||
return ""
|
||||
|
||||
route_prefix = self.get_route_prefix()
|
||||
columns = [
|
||||
'credit_type',
|
||||
'cases_shorted',
|
||||
'units_shorted',
|
||||
'credit_total',
|
||||
]
|
||||
g = grids.Grid(
|
||||
key='{}.row_credits'.format(route_prefix),
|
||||
data=row.credits,
|
||||
columns=columns,
|
||||
labels={'credit_type': "Type",
|
||||
'cases_shorted': "Cases",
|
||||
'units_shorted': "Units"})
|
||||
g.set_type('cases_shorted', 'quantity')
|
||||
g.set_type('units_shorted', 'quantity')
|
||||
g.set_type('credit_total', 'currency')
|
||||
return HTML.literal(g.render_grid())
|
||||
|
||||
def configure_mobile_row_form(self, f):
|
||||
super(PurchasingBatchView, self).configure_mobile_row_form(f)
|
||||
# row = f.model_instance
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue