Add new "v3" grids, refactor all views to use them
or at least that's the idea..hopefully we caught them all
This commit is contained in:
parent
f244c2934b
commit
5b1ae27a10
71 changed files with 2679 additions and 2030 deletions
|
@ -39,7 +39,7 @@ import formalchemy as fa
|
|||
import formencode as fe
|
||||
from webhelpers2.html import tags
|
||||
|
||||
from tailbone import forms, newgrids as grids
|
||||
from tailbone import forms, grids3 as grids
|
||||
from tailbone.views.purchasing import PurchasingBatchView
|
||||
|
||||
|
||||
|
@ -93,10 +93,36 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
mobile_creatable = True
|
||||
mobile_rows_filterable = True
|
||||
|
||||
row_grid_columns = [
|
||||
'sequence',
|
||||
'upc',
|
||||
# 'item_id',
|
||||
'brand_name',
|
||||
'description',
|
||||
'size',
|
||||
'cases_ordered',
|
||||
'units_ordered',
|
||||
'cases_received',
|
||||
'units_received',
|
||||
# 'po_total',
|
||||
'invoice_total',
|
||||
'credits',
|
||||
'status_code',
|
||||
]
|
||||
|
||||
@property
|
||||
def batch_mode(self):
|
||||
return self.enum.PURCHASE_BATCH_MODE_RECEIVING
|
||||
|
||||
def render_mobile_listitem(self, batch, i):
|
||||
title = "({}) {} for ${:0,.2f} - {}, {}".format(
|
||||
batch.id_str,
|
||||
batch.vendor,
|
||||
batch.po_total or 0,
|
||||
batch.department,
|
||||
batch.created_by)
|
||||
return title
|
||||
|
||||
def make_mobile_row_filters(self):
|
||||
"""
|
||||
Returns a set of filters for the mobile row grid.
|
||||
|
@ -158,10 +184,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
kwargs['sms_transaction_number'] = batch.sms_transaction_number
|
||||
return kwargs
|
||||
|
||||
def configure_mobile_grid(self, g):
|
||||
super(ReceivingBatchView, self).configure_mobile_grid(g)
|
||||
g.listitem.set(renderer=ReceivingBatchRenderer)
|
||||
|
||||
def configure_mobile_fieldset(self, fs):
|
||||
fs.configure(include=[
|
||||
fs.vendor.with_renderer(fa.TextFieldRenderer),
|
||||
|
@ -178,13 +200,9 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
else:
|
||||
del fs.complete
|
||||
|
||||
def render_mobile_row_listitem(self, row, **kwargs):
|
||||
if row is None:
|
||||
return ''
|
||||
def render_mobile_row_listitem(self, row, i):
|
||||
description = row.product.full_description if row.product else row.description
|
||||
title = "({}) {}".format(row.upc.pretty(), description)
|
||||
url = self.request.route_url('mobile.receiving.rows.view', uuid=row.uuid)
|
||||
return tags.link_to(title, url)
|
||||
return "({}) {}".format(row.upc.pretty(), description)
|
||||
|
||||
# TODO: this view can create new rows, with only a GET query. that should
|
||||
# probably be changed to require POST; for now we just require the "create
|
||||
|
@ -344,20 +362,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
cls._defaults(config)
|
||||
|
||||
|
||||
class ReceivingBatchRenderer(fa.FieldRenderer):
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
batch = self.raw_value
|
||||
title = "({}) {} for ${:0,.2f} - {}, {}".format(
|
||||
batch.id_str,
|
||||
batch.vendor,
|
||||
batch.po_total or 0,
|
||||
batch.department,
|
||||
batch.created_by)
|
||||
url = self.request.route_url('mobile.receiving.view', uuid=batch.uuid)
|
||||
return tags.link_to(title, url)
|
||||
|
||||
|
||||
class ValidBatchRow(forms.validators.ModelValidator):
|
||||
model_class = model.PurchaseBatchRow
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue