More tweaks to vendor catalog/invoice batches.

Trying to make batch fieldsets simpler to configure...
This commit is contained in:
Lance Edgar 2016-02-14 19:56:56 -06:00
parent 874fd6d4b3
commit bc1c7b3554
3 changed files with 36 additions and 32 deletions

View file

@ -62,7 +62,7 @@ class BatchMasterView(MasterView):
"""
Base class for all "batch master" views.
"""
refreshable = False
refreshable = True
rows_viewable = True
rows_creatable = False
rows_editable = False
@ -205,6 +205,24 @@ class BatchMasterView(MasterView):
fs.created_by,
])
def _postconfigure_fieldset(self, fs):
if self.creating:
if 'created' in fs.render_fields:
del fs.created
if 'created_by' in fs.render_fields:
del fs.created_by
if 'executed' in fs.render_fields:
del fs.executed
if 'executed_by' in fs.render_fields:
del fs.executed_by
else:
batch = fs.model
if not batch.executed:
if 'executed' in fs.render_fields:
del fs.executed
if 'executed_by' in fs.render_fields:
del fs.executed_by
def save_create_form(self, form):
"""
Save the uploaded data file if necessary, etc. If batch initialization
@ -527,7 +545,7 @@ class BatchMasterView(MasterView):
return defaults
def row_grid_row_attrs(self, row, i):
pass
return {}
def view_row(self):
"""
@ -769,7 +787,6 @@ class FileBatchMasterView(BatchMasterView):
"""
Base class for all file-based "batch master" views.
"""
refreshable = True
@property
def upload_dir(self):

View file

@ -85,7 +85,6 @@ class VendorCatalogsView(FileBatchMasterView):
parser_options.insert(0, ("(please choose)", ''))
fs.parser_key.set(renderer=formalchemy.fields.SelectFieldRenderer,
options=parser_options, label="File Type")
fs.configure(
include=[
fs.filename,
@ -94,7 +93,6 @@ class VendorCatalogsView(FileBatchMasterView):
])
else:
fs.configure(
include=[
fs.vendor.readonly(),
@ -106,11 +104,6 @@ class VendorCatalogsView(FileBatchMasterView):
fs.executed_by,
])
batch = fs.model
if not batch.executed:
del fs.executed
del fs.executed_by
def configure_row_grid(self, g):
g.configure(
include=[

View file

@ -68,6 +68,19 @@ class VendorInvoicesView(FileBatchMasterView):
fs.purchase_order_number.set(validate=self.validate_po_number)
fs.filename.set(label="Invoice File")
fs.configure(
include=[
fs.vendor.readonly(),
fs.filename,
fs.parser_key,
fs.purchase_order_number,
fs.invoice_date.readonly(),
fs.created,
fs.created_by,
fs.executed,
fs.executed_by,
])
if self.creating:
parsers = sorted(iter_invoice_parsers(), key=lambda p: p.display)
parser_options = [(p.display, p.key) for p in parsers]
@ -75,30 +88,11 @@ class VendorInvoicesView(FileBatchMasterView):
fs.parser_key.set(label="File Type",
renderer=formalchemy.fields.SelectFieldRenderer,
options=parser_options)
fs.configure(
include=[
fs.filename,
fs.parser_key,
fs.purchase_order_number,
])
del fs.vendor
del fs.invoice_date
else:
fs.configure(
include=[
fs.vendor.readonly(),
fs.filename,
fs.purchase_order_number,
fs.invoice_date.readonly(),
fs.created,
fs.created_by,
fs.executed,
fs.executed_by,
])
batch = fs.model
if not batch.executed:
del fs.executed
del fs.executed_by
del fs.parser_key
def validate_po_number(self, value, field):
"""