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:
Lance Edgar 2017-07-07 09:13:53 -05:00
parent f244c2934b
commit 5b1ae27a10
71 changed files with 2679 additions and 2030 deletions

View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8; -*-
################################################################################
#
# Rattail -- Retail Software Framework
@ -29,4 +29,4 @@ from __future__ import unicode_literals, absolute_import
def includeme(config):
config.include('tailbone.views.purchases.core')
config.include('tailbone.views.purchases.batch')
config.include('tailbone.views.purchases.credits')

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@ from webhelpers2.html import HTML, tags
from tailbone import forms
from tailbone.db import Session
from tailbone.views import MasterView
from tailbone.views import MasterView2 as MasterView
class BatchesFieldRenderer(fa.FieldRenderer):
@ -73,6 +73,32 @@ class PurchaseView(MasterView):
model_row_class = model.PurchaseItem
row_model_title = 'Purchase Item'
grid_columns = [
'store',
'vendor',
'department',
'buyer',
'date_ordered',
'date_received',
'invoice_number',
'status',
]
row_grid_columns = [
'sequence',
'upc',
'item_id',
'brand_name',
'description',
'size',
'cases_ordered',
'units_ordered',
'cases_received',
'units_received',
'po_total',
'invoice_total',
]
def get_instance_title(self, purchase):
if purchase.status >= self.enum.PURCHASE_STATUS_COSTED:
if purchase.invoice_date:
@ -90,7 +116,9 @@ class PurchaseView(MasterView):
return "{} (ordered)".format(purchase.vendor)
return unicode(purchase)
def _preconfigure_grid(self, g):
def configure_grid(self, g):
super(PurchaseView, self).configure_grid(g)
g.joiners['store'] = lambda q: q.join(model.Store)
g.filters['store'] = g.make_filter('store', model.Store.name)
g.sorters['store'] = g.make_sorter(model.Store.name)
@ -116,24 +144,11 @@ class PurchaseView(MasterView):
g.default_sortkey = 'date_ordered'
g.default_sortdir = 'desc'
g.date_ordered.set(label="Ordered")
g.date_received.set(label="Received")
g.invoice_number.set(label="Invoice No.")
g.status.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.PURCHASE_STATUS))
g.set_enum('status', self.enum.PURCHASE_STATUS)
def configure_grid(self, g):
g.configure(
include=[
g.store,
g.vendor,
g.department,
g.buyer,
g.date_ordered,
g.date_received,
g.invoice_number,
g.status,
],
readonly=True)
g.set_label('date_ordered', "Ordered")
g.set_label('date_received', "Received")
g.set_label('invoice_number', "Invoice No.")
def _preconfigure_fieldset(self, fs):
fs.store.set(renderer=forms.renderers.StoreFieldRenderer)
@ -189,43 +204,36 @@ class PurchaseView(MasterView):
return Session.query(model.PurchaseItem)\
.filter(model.PurchaseItem.purchase == purchase)
def _preconfigure_row_grid(self, g):
g.default_sortkey = 'sequence'
g.sequence.set(label="Seq")
g.upc.set(label="UPC")
g.brand_name.set(label="Brand")
g.cases_ordered.set(label="Cases Ord.", renderer=forms.renderers.QuantityFieldRenderer)
g.units_ordered.set(label="Units Ord.", renderer=forms.renderers.QuantityFieldRenderer)
g.cases_received.set(label="Cases Rec.", renderer=forms.renderers.QuantityFieldRenderer)
g.units_received.set(label="Units Rec.", renderer=forms.renderers.QuantityFieldRenderer)
g.po_total.set(label="Total", renderer=forms.renderers.CurrencyFieldRenderer)
g.invoice_total.set(label="Total", renderer=forms.renderers.CurrencyFieldRenderer)
def configure_row_grid(self, g):
super(PurchaseView, self).configure_row_grid(g)
g.default_sortkey = 'sequence'
g.set_type('cases_ordered', 'quantity')
g.set_type('units_ordered', 'quantity')
g.set_type('cases_received', 'quantity')
g.set_type('units_received', 'quantity')
g.set_type('po_total', 'currency')
g.set_type('invoice_total', 'currency')
g.set_label('sequence', "Seq")
g.set_label('upc', "UPC")
g.set_label('brand_name', "Brand")
g.set_label('cases_ordered', "Cases Ord.")
g.set_label('units_ordered', "Units Ord.")
g.set_label('cases_received', "Cases Rec.")
g.set_label('units_received', "Units Rec.")
g.set_label('po_total', "Total")
g.set_label('invoice_total', "Total")
purchase = self.get_instance()
g.configure(
include=[
g.sequence,
g.upc,
g.item_id,
g.brand_name,
g.description,
g.size,
g.cases_ordered,
g.units_ordered,
g.cases_received,
g.units_received,
g.po_total,
g.invoice_total,
],
readonly=True)
if purchase.status == self.enum.PURCHASE_STATUS_ORDERED:
del g.cases_received
del g.units_received
del g.invoice_total
g.hide_column('cases_received')
g.hide_column('units_received')
g.hide_column('invoice_total')
elif purchase.status in (self.enum.PURCHASE_STATUS_RECEIVED,
self.enum.PURCHASE_STATUS_COSTED):
del g.po_total
g.hide_column('po_total')
def _preconfigure_row_fieldset(self, fs):
fs.vendor_code.set(label="Vendor Item Code")

View file

@ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import
from rattail.db import model
from tailbone import forms
from tailbone.views import MasterView
from tailbone.views import MasterView2 as MasterView
class PurchaseCreditView(MasterView):
@ -42,7 +42,21 @@ class PurchaseCreditView(MasterView):
creatable = False
editable = False
def _preconfigure_grid(self, g):
grid_columns = [
'vendor',
'upc',
'brand_name',
'description',
'size',
'cases_shorted',
'units_shorted',
'credit_type',
'date_received',
'status',
]
def configure_grid(self, g):
super(PurchaseCreditView, self).configure_grid(g)
g.joiners['vendor'] = lambda q: q.outerjoin(model.Vendor)
g.sorters['vendor'] = g.make_sorter(model.Vendor.name)
@ -50,28 +64,15 @@ class PurchaseCreditView(MasterView):
g.default_sortkey = 'date_received'
g.default_sortdir = 'desc'
g.upc.set(label="UPC")
g.brand_name.set(label="Brand")
g.cases_shorted.set(label="Cases", renderer=forms.renderers.QuantityFieldRenderer)
g.units_shorted.set(label="Units", renderer=forms.renderers.QuantityFieldRenderer)
g.credit_type.set(label="Type")
g.date_received.set(label="Date")
g.set_type('cases_shorted', 'quantity')
g.set_type('units_shorted', 'quantity')
def configure_grid(self, g):
g.configure(
include=[
g.vendor,
g.upc,
g.brand_name,
g.description,
g.size,
g.cases_shorted,
g.units_shorted,
g.credit_type,
g.date_received,
g.status,
],
readonly=True)
g.set_label('upc', "UPC")
g.set_label('brand_name', "Brand")
g.set_label('cases_shorted', "Cases")
g.set_label('units_shorted', "Units")
g.set_label('credit_type', "Type")
g.set_label('date_received', "Date")
def includeme(config):