Refactor trainwreck views per master4

This commit is contained in:
Lance Edgar 2018-02-04 12:54:20 -06:00
parent 38afb35b65
commit 4ab41ba82e

View file

@ -30,9 +30,8 @@ import six
from rattail.time import localtime from rattail.time import localtime
from tailbone import forms
from tailbone.db import TrainwreckSession from tailbone.db import TrainwreckSession
from tailbone.views import MasterView3 as MasterView from tailbone.views import MasterView4 as MasterView
class TransactionView(MasterView): class TransactionView(MasterView):
@ -49,6 +48,10 @@ class TransactionView(MasterView):
editable = False editable = False
deletable = False deletable = False
labels = {
'cashback': "Cash Back",
}
grid_columns = [ grid_columns = [
'start_time', 'start_time',
'system', 'system',
@ -60,27 +63,6 @@ class TransactionView(MasterView):
'total', 'total',
] ]
labels = {
'cashback': "Cash Back",
}
has_rows = True
# model_row_class = trainwreck.TransactionItem
rows_default_pagesize = 100
row_grid_columns = [
'sequence',
'item_type',
'item_scancode',
'department_number',
'description',
'unit_quantity',
'subtotal',
'tax',
'total',
'void',
]
form_fields = [ form_fields = [
'system', 'system',
'system_id', 'system_id',
@ -103,6 +85,42 @@ class TransactionView(MasterView):
'void', 'void',
] ]
has_rows = True
# model_row_class = trainwreck.TransactionItem
rows_default_pagesize = 100
row_labels = {
'item_id': "Item ID",
'department_number': "Dept. No.",
}
row_grid_columns = [
'sequence',
'item_type',
'item_scancode',
'department_number',
'description',
'unit_quantity',
'subtotal',
'tax',
'total',
'void',
]
row_form_fields = [
'sequence',
'item_type',
'item_scancode',
'item_id',
'department_number',
'description',
'unit_quantity',
'subtotal',
'tax',
'total',
'void',
]
def configure_grid(self, g): def configure_grid(self, g):
super(TransactionView, self).configure_grid(g) super(TransactionView, self).configure_grid(g)
g.filters['receipt_number'].default_active = True g.filters['receipt_number'].default_active = True
@ -162,29 +180,14 @@ class TransactionView(MasterView):
g.set_type('tax', 'currency') g.set_type('tax', 'currency')
g.set_type('total', 'currency') g.set_type('total', 'currency')
g.set_label('item_id', "Item ID") def configure_row_form(self, f):
g.set_label('department_number', "Dept. No.") super(TransactionView, self).configure_row_form(f)
def _preconfigure_row_fieldset(self, fs): # quantity fields
fs.item_id.set(label="Item ID") f.set_type('unit_quantity', 'quantity')
fs.department_number.set(label="Dept. No.")
fs.unit_quantity.set(renderer=forms.renderers.QuantityFieldRenderer)
fs.subtotal.set(renderer=forms.renderers.CurrencyFieldRenderer)
fs.discounted_subtotal.set(renderer=forms.renderers.CurrencyFieldRenderer)
fs.tax.set(renderer=forms.renderers.CurrencyFieldRenderer)
fs.total.set(renderer=forms.renderers.CurrencyFieldRenderer)
def configure_row_fieldset(self, fs): # currency fields
fs.configure(include=[ f.set_type('subtotal', 'currency')
fs.sequence, f.set_type('discounted_subtotal', 'currency')
fs.item_type, f.set_type('tax', 'currency')
fs.item_scancode, f.set_type('total', 'currency')
fs.item_id,
fs.department_number,
fs.description,
fs.unit_quantity,
fs.subtotal,
fs.tax,
fs.total,
fs.void,
])