Refactor label batch views per master4

This commit is contained in:
Lance Edgar 2018-02-04 10:58:30 -06:00
parent 88fe195615
commit 0737faa034

View file

@ -30,7 +30,7 @@ from rattail.db import model
from webhelpers2.html import HTML, tags
from tailbone.views.batch import BatchMasterView3 as BatchMasterView
from tailbone.views.batch import BatchMasterView4 as BatchMasterView
class LabelBatchView(BatchMasterView):
@ -76,6 +76,37 @@ class LabelBatchView(BatchMasterView):
'executed_by',
]
row_labels = {
'upc': "UPC",
'vendor_id': "Vendor ID",
'label_profile': "Label Type",
}
row_form_fields = [
'sequence',
'upc',
'product',
'brand_name',
'description',
'size',
'department_number',
'department_name',
'regular_price',
'pack_quantity',
'pack_price',
'sale_price',
'sale_start',
'sale_stop',
'vendor_id',
'vendor_name',
'vendor_item_code',
'case_quantity',
'label_profile',
'label_quantity',
'status_code',
'status_text',
]
def configure_form(self, f):
super(LabelBatchView, self).configure_form(f)
@ -98,82 +129,57 @@ class LabelBatchView(BatchMasterView):
def configure_row_grid(self, g):
super(LabelBatchView, self).configure_row_grid(g)
g.set_label('upc', "UPC")
# short labels
g.set_label('brand_name', "Brand")
g.set_label('regular_price', "Reg Price")
g.set_label('label_profile', "Label Type")
g.set_label('label_quantity', "Qty")
def row_grid_extra_class(self, row, i):
if row.status_code != row.STATUS_OK:
return 'warning'
def _preconfigure_row_fieldset(self, fs):
fs.sequence.set(readonly=True)
fs.product.set(readonly=True)
fs.upc.set(readonly=True, label="UPC")
fs.brand_name.set(readonly=True)
fs.description.set(readonly=True)
fs.size.set(readonly=True)
fs.department_number.set(readonly=True)
fs.department_name.set(readonly=True)
fs.regular_price.set(readonly=True)
fs.pack_quantity.set(readonly=True)
fs.pack_price.set(readonly=True)
fs.sale_price.set(readonly=True)
fs.sale_start.set(readonly=True)
fs.sale_stop.set(readonly=True)
fs.vendor_id.set(readonly=True, label="Vendor ID")
fs.vendor_name.set(readonly=True)
fs.vendor_item_code.set(readonly=True)
fs.case_quantity.set(readonly=True)
fs.status_code.set(readonly=True)
fs.status_text.set(readonly=True)
def configure_row_form(self, f):
super(LabelBatchView, self).configure_row_form(f)
fs.label_profile.set(label="Label Type")
# readonly fields
f.set_readonly('sequence')
f.set_readonly('product')
f.set_readonly('upc')
f.set_readonly('brand_name')
f.set_readonly('description')
f.set_readonly('size')
f.set_readonly('department_number')
f.set_readonly('department_name')
f.set_readonly('regular_price')
f.set_readonly('pack_quantity')
f.set_readonly('pack_price')
f.set_readonly('sale_price')
f.set_readonly('sale_start')
f.set_readonly('sale_stop')
f.set_readonly('vendor_id')
f.set_readonly('vendor_name')
f.set_readonly('vendor_item_code')
f.set_readonly('case_quantity')
f.set_readonly('status_code')
f.set_readonly('status_text')
def configure_row_fieldset(self, fs):
if self.viewing:
fs.configure(
include=[
fs.sequence,
fs.upc,
fs.brand_name,
fs.description,
fs.size,
fs.department_number,
fs.department_name,
fs.regular_price,
fs.pack_quantity,
fs.pack_price,
fs.sale_price,
fs.sale_start,
fs.sale_stop,
fs.vendor_id,
fs.vendor_name,
fs.vendor_item_code,
fs.case_quantity,
fs.label_profile,
fs.label_quantity,
fs.status_code,
fs.status_text,
])
elif self.editing:
fs.configure(
include=[
fs.sequence,
fs.upc,
fs.product,
fs.department_number,
fs.department_name,
fs.regular_price,
fs.sale_price,
fs.label_profile,
fs.label_quantity,
fs.status_code,
fs.status_text,
])
if self.editing:
f.remove_fields(
'brand_name',
'description',
'size',
'pack_quantity',
'pack_price',
'sale_start',
'sale_stop',
'vendor_id',
'vendor_name',
'vendor_item_code',
'case_quantity',
)
else:
f.remove_field('product')
def includeme(config):