Add support for inactivity_months field for delete product batch

This commit is contained in:
Lance Edgar 2021-03-09 11:44:56 -06:00
parent 059b24fac7
commit 7532dc5117
2 changed files with 49 additions and 19 deletions

View file

@ -45,6 +45,19 @@ class DeleteProductBatchView(BatchMasterView):
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 = [
'sequence',
'upc',

View file

@ -1608,6 +1608,7 @@ class ProductView(MasterView):
if self.request.method == 'POST':
if form.validate(newstyle=True):
data = form.validated
fully_validated = True
# collect general params
batch_key = data['batch_type']
@ -1617,11 +1618,16 @@ class ProductView(MasterView):
# collect batch-type-specific params
pform = params_forms.get(batch_key)
if pform and pform.validate(newstyle=True):
if pform:
if pform.validate(newstyle=True):
pdata = pform.validated
for field in pform.schema:
param_name = pform.schema[field.name].param_name
params[param_name] = pdata[field.name]
else:
fully_validated = False
if fully_validated:
# TODO: should this be done elsewhere?
for name in params:
@ -1668,6 +1674,17 @@ class ProductView(MasterView):
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):
"""
Threat target for making a batch from current products query.