Let "new product" batch override type-2 UPC lookup behavior
This commit is contained in:
parent
74678882ee
commit
f4267737c3
|
@ -26,6 +26,8 @@ Views for new product batches
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
|
|
||||||
|
from deform import widget as dfwidget
|
||||||
|
|
||||||
from tailbone.views.batch import BatchMasterView
|
from tailbone.views.batch import BatchMasterView
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,11 +49,17 @@ class NewProductBatchView(BatchMasterView):
|
||||||
configurable = True
|
configurable = True
|
||||||
has_input_file_templates = True
|
has_input_file_templates = True
|
||||||
|
|
||||||
|
labels = {
|
||||||
|
'type2_lookup': "Type-2 UPC Lookups",
|
||||||
|
}
|
||||||
|
|
||||||
form_fields = [
|
form_fields = [
|
||||||
'id',
|
'id',
|
||||||
'input_filename',
|
'input_filename',
|
||||||
'description',
|
'description',
|
||||||
'notes',
|
'notes',
|
||||||
|
'type2_lookup',
|
||||||
|
'params',
|
||||||
'created',
|
'created',
|
||||||
'created_by',
|
'created_by',
|
||||||
'rowcount',
|
'rowcount',
|
||||||
|
@ -127,7 +135,7 @@ class NewProductBatchView(BatchMasterView):
|
||||||
]
|
]
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(NewProductBatchView, self).configure_form(f)
|
super().configure_form(f)
|
||||||
|
|
||||||
# input_filename
|
# input_filename
|
||||||
if self.creating:
|
if self.creating:
|
||||||
|
@ -136,6 +144,34 @@ class NewProductBatchView(BatchMasterView):
|
||||||
f.set_readonly('input_filename')
|
f.set_readonly('input_filename')
|
||||||
f.set_renderer('input_filename', self.render_downloadable_file)
|
f.set_renderer('input_filename', self.render_downloadable_file)
|
||||||
|
|
||||||
|
# type2_lookup
|
||||||
|
if self.creating:
|
||||||
|
values = [
|
||||||
|
('', "(use default behavior)"),
|
||||||
|
('always', "Always try Type-2 lookup, when applicable"),
|
||||||
|
('never', "Never try Type-2 lookup"),
|
||||||
|
]
|
||||||
|
f.set_widget('type2_lookup', dfwidget.SelectWidget(values=values))
|
||||||
|
f.set_default('type2_lookup', '')
|
||||||
|
else:
|
||||||
|
f.remove('type2_lookup')
|
||||||
|
|
||||||
|
def save_create_form(self, form):
|
||||||
|
batch = super().save_create_form(form)
|
||||||
|
|
||||||
|
if 'type2_lookup' in form:
|
||||||
|
type2_lookup = form.validated['type2_lookup']
|
||||||
|
if type2_lookup == 'always':
|
||||||
|
type2_lookup = True
|
||||||
|
elif type2_lookup == 'never':
|
||||||
|
type2_lookup = False
|
||||||
|
else:
|
||||||
|
type2_lookup = None
|
||||||
|
if type2_lookup is not None:
|
||||||
|
batch.set_param('type2_lookup', type2_lookup)
|
||||||
|
|
||||||
|
return batch
|
||||||
|
|
||||||
def configure_row_grid(self, g):
|
def configure_row_grid(self, g):
|
||||||
super(NewProductBatchView, self).configure_row_grid(g)
|
super(NewProductBatchView, self).configure_row_grid(g)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue