More tweaks to vendor catalog/invoice batches.
Trying to make batch fieldsets simpler to configure...
This commit is contained in:
parent
874fd6d4b3
commit
bc1c7b3554
|
@ -62,7 +62,7 @@ class BatchMasterView(MasterView):
|
||||||
"""
|
"""
|
||||||
Base class for all "batch master" views.
|
Base class for all "batch master" views.
|
||||||
"""
|
"""
|
||||||
refreshable = False
|
refreshable = True
|
||||||
rows_viewable = True
|
rows_viewable = True
|
||||||
rows_creatable = False
|
rows_creatable = False
|
||||||
rows_editable = False
|
rows_editable = False
|
||||||
|
@ -205,6 +205,24 @@ class BatchMasterView(MasterView):
|
||||||
fs.created_by,
|
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):
|
def save_create_form(self, form):
|
||||||
"""
|
"""
|
||||||
Save the uploaded data file if necessary, etc. If batch initialization
|
Save the uploaded data file if necessary, etc. If batch initialization
|
||||||
|
@ -527,7 +545,7 @@ class BatchMasterView(MasterView):
|
||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
def row_grid_row_attrs(self, row, i):
|
def row_grid_row_attrs(self, row, i):
|
||||||
pass
|
return {}
|
||||||
|
|
||||||
def view_row(self):
|
def view_row(self):
|
||||||
"""
|
"""
|
||||||
|
@ -769,7 +787,6 @@ class FileBatchMasterView(BatchMasterView):
|
||||||
"""
|
"""
|
||||||
Base class for all file-based "batch master" views.
|
Base class for all file-based "batch master" views.
|
||||||
"""
|
"""
|
||||||
refreshable = True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_dir(self):
|
def upload_dir(self):
|
||||||
|
|
7
tailbone/views/vendors/catalogs.py
vendored
7
tailbone/views/vendors/catalogs.py
vendored
|
@ -85,7 +85,6 @@ class VendorCatalogsView(FileBatchMasterView):
|
||||||
parser_options.insert(0, ("(please choose)", ''))
|
parser_options.insert(0, ("(please choose)", ''))
|
||||||
fs.parser_key.set(renderer=formalchemy.fields.SelectFieldRenderer,
|
fs.parser_key.set(renderer=formalchemy.fields.SelectFieldRenderer,
|
||||||
options=parser_options, label="File Type")
|
options=parser_options, label="File Type")
|
||||||
|
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
fs.filename,
|
fs.filename,
|
||||||
|
@ -94,7 +93,6 @@ class VendorCatalogsView(FileBatchMasterView):
|
||||||
])
|
])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
fs.vendor.readonly(),
|
fs.vendor.readonly(),
|
||||||
|
@ -106,11 +104,6 @@ class VendorCatalogsView(FileBatchMasterView):
|
||||||
fs.executed_by,
|
fs.executed_by,
|
||||||
])
|
])
|
||||||
|
|
||||||
batch = fs.model
|
|
||||||
if not batch.executed:
|
|
||||||
del fs.executed
|
|
||||||
del fs.executed_by
|
|
||||||
|
|
||||||
def configure_row_grid(self, g):
|
def configure_row_grid(self, g):
|
||||||
g.configure(
|
g.configure(
|
||||||
include=[
|
include=[
|
||||||
|
|
34
tailbone/views/vendors/invoices.py
vendored
34
tailbone/views/vendors/invoices.py
vendored
|
@ -68,26 +68,11 @@ class VendorInvoicesView(FileBatchMasterView):
|
||||||
fs.purchase_order_number.set(validate=self.validate_po_number)
|
fs.purchase_order_number.set(validate=self.validate_po_number)
|
||||||
fs.filename.set(label="Invoice File")
|
fs.filename.set(label="Invoice File")
|
||||||
|
|
||||||
if self.creating:
|
|
||||||
parsers = sorted(iter_invoice_parsers(), key=lambda p: p.display)
|
|
||||||
parser_options = [(p.display, p.key) for p in parsers]
|
|
||||||
parser_options.insert(0, ("(please choose)", ''))
|
|
||||||
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,
|
|
||||||
])
|
|
||||||
|
|
||||||
else:
|
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
fs.vendor.readonly(),
|
fs.vendor.readonly(),
|
||||||
fs.filename,
|
fs.filename,
|
||||||
|
fs.parser_key,
|
||||||
fs.purchase_order_number,
|
fs.purchase_order_number,
|
||||||
fs.invoice_date.readonly(),
|
fs.invoice_date.readonly(),
|
||||||
fs.created,
|
fs.created,
|
||||||
|
@ -95,10 +80,19 @@ class VendorInvoicesView(FileBatchMasterView):
|
||||||
fs.executed,
|
fs.executed,
|
||||||
fs.executed_by,
|
fs.executed_by,
|
||||||
])
|
])
|
||||||
batch = fs.model
|
|
||||||
if not batch.executed:
|
if self.creating:
|
||||||
del fs.executed
|
parsers = sorted(iter_invoice_parsers(), key=lambda p: p.display)
|
||||||
del fs.executed_by
|
parser_options = [(p.display, p.key) for p in parsers]
|
||||||
|
parser_options.insert(0, ("(please choose)", ''))
|
||||||
|
fs.parser_key.set(label="File Type",
|
||||||
|
renderer=formalchemy.fields.SelectFieldRenderer,
|
||||||
|
options=parser_options)
|
||||||
|
del fs.vendor
|
||||||
|
del fs.invoice_date
|
||||||
|
|
||||||
|
else:
|
||||||
|
del fs.parser_key
|
||||||
|
|
||||||
def validate_po_number(self, value, field):
|
def validate_po_number(self, value, field):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue