Add support for inactivity_months
field for delete product batch
This commit is contained in:
parent
059b24fac7
commit
7532dc5117
|
@ -45,6 +45,19 @@ class DeleteProductBatchView(BatchMasterView):
|
||||||
bulk_deletable = True
|
bulk_deletable = True
|
||||||
rows_bulk_deletable = True
|
rows_bulk_deletable = True
|
||||||
|
|
||||||
|
form_fields = [
|
||||||
|
'id',
|
||||||
|
'description',
|
||||||
|
'notes',
|
||||||
|
'inactivity_months',
|
||||||
|
'created',
|
||||||
|
'created_by',
|
||||||
|
'rowcount',
|
||||||
|
'status_code',
|
||||||
|
'executed',
|
||||||
|
'executed_by',
|
||||||
|
]
|
||||||
|
|
||||||
row_grid_columns = [
|
row_grid_columns = [
|
||||||
'sequence',
|
'sequence',
|
||||||
'upc',
|
'upc',
|
||||||
|
|
|
@ -1608,6 +1608,7 @@ class ProductView(MasterView):
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
if form.validate(newstyle=True):
|
if form.validate(newstyle=True):
|
||||||
data = form.validated
|
data = form.validated
|
||||||
|
fully_validated = True
|
||||||
|
|
||||||
# collect general params
|
# collect general params
|
||||||
batch_key = data['batch_type']
|
batch_key = data['batch_type']
|
||||||
|
@ -1617,27 +1618,32 @@ class ProductView(MasterView):
|
||||||
|
|
||||||
# collect batch-type-specific params
|
# collect batch-type-specific params
|
||||||
pform = params_forms.get(batch_key)
|
pform = params_forms.get(batch_key)
|
||||||
if pform and pform.validate(newstyle=True):
|
if pform:
|
||||||
pdata = pform.validated
|
if pform.validate(newstyle=True):
|
||||||
for field in pform.schema:
|
pdata = pform.validated
|
||||||
param_name = pform.schema[field.name].param_name
|
for field in pform.schema:
|
||||||
params[param_name] = pdata[field.name]
|
param_name = pform.schema[field.name].param_name
|
||||||
|
params[param_name] = pdata[field.name]
|
||||||
|
else:
|
||||||
|
fully_validated = False
|
||||||
|
|
||||||
# TODO: should this be done elsewhere?
|
if fully_validated:
|
||||||
for name in params:
|
|
||||||
if params[name] is colander.null:
|
|
||||||
params[name] = None
|
|
||||||
|
|
||||||
handler = supported[batch_key]
|
# TODO: should this be done elsewhere?
|
||||||
products = self.get_products_for_batch(batch_key)
|
for name in params:
|
||||||
progress = self.make_progress('products.batch')
|
if params[name] is colander.null:
|
||||||
thread = Thread(target=self.make_batch_thread,
|
params[name] = None
|
||||||
args=(handler, self.request.user.uuid, products, params, progress))
|
|
||||||
thread.start()
|
handler = supported[batch_key]
|
||||||
return self.render_progress(progress, {
|
products = self.get_products_for_batch(batch_key)
|
||||||
'cancel_url': self.get_index_url(),
|
progress = self.make_progress('products.batch')
|
||||||
'cancel_msg': "Batch creation was canceled.",
|
thread = Thread(target=self.make_batch_thread,
|
||||||
})
|
args=(handler, self.request.user.uuid, products, params, progress))
|
||||||
|
thread.start()
|
||||||
|
return self.render_progress(progress, {
|
||||||
|
'cancel_url': self.get_index_url(),
|
||||||
|
'cancel_msg': "Batch creation was canceled.",
|
||||||
|
})
|
||||||
|
|
||||||
return self.render_to_response('batch', {
|
return self.render_to_response('batch', {
|
||||||
'form': form,
|
'form': form,
|
||||||
|
@ -1668,6 +1674,17 @@ class ProductView(MasterView):
|
||||||
colander.SchemaNode(colander.Boolean(), name='calculate_for_manual'),
|
colander.SchemaNode(colander.Boolean(), name='calculate_for_manual'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def make_batch_params_schema_delproduct(self):
|
||||||
|
"""
|
||||||
|
Return params schema for making a "delete products" batch.
|
||||||
|
"""
|
||||||
|
return colander.SchemaNode(
|
||||||
|
colander.Mapping(),
|
||||||
|
colander.SchemaNode(colander.Integer(), name='inactivity_months',
|
||||||
|
# TODO: probably should be configurable
|
||||||
|
default=18),
|
||||||
|
)
|
||||||
|
|
||||||
def make_batch_thread(self, handler, user_uuid, products, params, progress):
|
def make_batch_thread(self, handler, user_uuid, products, params, progress):
|
||||||
"""
|
"""
|
||||||
Threat target for making a batch from current products query.
|
Threat target for making a batch from current products query.
|
||||||
|
|
Loading…
Reference in a new issue