Add start date support for "future" pricing batch

This commit is contained in:
Lance Edgar 2022-06-14 13:51:00 -05:00
parent cb6499522e
commit 6b466bb90f
3 changed files with 68 additions and 4 deletions

View file

@ -1892,14 +1892,15 @@ class ProductView(MasterView):
return {'product': data}
def get_supported_batches(self):
app = self.get_rattail_app()
pricing = app.get_batch_handler('pricing')
return OrderedDict([
('labels', {
'spec': self.rattail_config.get('rattail.batch', 'labels.handler',
default='rattail.batch.labels:LabelBatchHandler'),
}),
('pricing', {
'spec': self.rattail_config.get('rattail.batch', 'pricing.handler',
default='rattail.batch.pricing:PricingBatchHandler'),
'spec': pricing.get_spec(),
}),
('delproduct', {
'spec': self.rattail_config.get('rattail.batch', 'delproduct.handler',
@ -2003,7 +2004,9 @@ class ProductView(MasterView):
"""
Return params schema for making a pricing batch.
"""
return colander.SchemaNode(
app = self.get_rattail_app()
schema = colander.SchemaNode(
colander.Mapping(),
colander.SchemaNode(colander.Decimal(), name='min_diff_threshold',
quant='1.00', missing=colander.null,
@ -2014,6 +2017,17 @@ class ProductView(MasterView):
colander.SchemaNode(colander.Boolean(), name='calculate_for_manual'),
)
pricing = app.get_batch_handler('pricing')
if pricing.allow_future():
schema.insert(0, colander.SchemaNode(
colander.Date(),
name='start_date',
missing=colander.null,
title="Start Date (FUTURE only)",
widget=forms.widgets.JQueryDateWidget()))
return schema
def make_batch_params_schema_delproduct(self):
"""
Return params schema for making a "delete products" batch.