Allow restricting to supported vendors only, for Receiving
This commit is contained in:
parent
e3b1be5835
commit
cff4942769
|
@ -3,9 +3,13 @@
|
||||||
|
|
||||||
<%def name="form_content()">
|
<%def name="form_content()">
|
||||||
|
|
||||||
<h3 class="block is-size-3">Supported Workflows</h3>
|
<h3 class="block is-size-3">Workflows</h3>
|
||||||
<div class="block" style="padding-left: 2rem;">
|
<div class="block" style="padding-left: 2rem;">
|
||||||
|
|
||||||
|
<p class="block">
|
||||||
|
Users can only choose from the workflows enabled below.
|
||||||
|
</p>
|
||||||
|
|
||||||
<b-field>
|
<b-field>
|
||||||
<b-checkbox name="rattail.batch.purchase.allow_receiving_from_scratch"
|
<b-checkbox name="rattail.batch.purchase.allow_receiving_from_scratch"
|
||||||
v-model="simpleSettings['rattail.batch.purchase.allow_receiving_from_scratch']"
|
v-model="simpleSettings['rattail.batch.purchase.allow_receiving_from_scratch']"
|
||||||
|
@ -53,6 +57,20 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h3 class="block is-size-3">Vendors</h3>
|
||||||
|
<div class="block" style="padding-left: 2rem;">
|
||||||
|
|
||||||
|
<b-field message="If set, user must choose a "supported" vendor; otherwise they may choose "any" vendor.">
|
||||||
|
<b-checkbox name="rattail.batch.purchase.supported_vendors_only"
|
||||||
|
v-model="simpleSettings['rattail.batch.purchase.supported_vendors_only']"
|
||||||
|
native-value="true"
|
||||||
|
@input="settingsNeedSaved = true">
|
||||||
|
Only allow batch for "supported" vendors
|
||||||
|
</b-checkbox>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3 class="block is-size-3">Display</h3>
|
<h3 class="block is-size-3">Display</h3>
|
||||||
<div class="block" style="padding-left: 2rem;">
|
<div class="block" style="padding-left: 2rem;">
|
||||||
|
|
||||||
|
|
|
@ -311,26 +311,44 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
# configure vendor field
|
# configure vendor field
|
||||||
app = self.get_rattail_app()
|
app = self.get_rattail_app()
|
||||||
vendor_handler = app.get_vendor_handler()
|
vendor_handler = app.get_vendor_handler()
|
||||||
use_dropdown = vendor_handler.choice_uses_dropdown()
|
if self.rattail_config.getbool('rattail.batch', 'purchase.supported_vendors_only'):
|
||||||
if use_dropdown:
|
# only show vendors for which we have dedicated invoice parsers
|
||||||
vendors = self.Session.query(model.Vendor)\
|
vendors = {}
|
||||||
.order_by(model.Vendor.id)
|
for parser in self.batch_handler.get_supported_invoice_parsers():
|
||||||
vendor_values = [(vendor.uuid, "({}) {}".format(vendor.id, vendor.name))
|
if parser.vendor_key:
|
||||||
|
vendor = vendor_handler.get_vendor(self.Session(),
|
||||||
|
parser.vendor_key)
|
||||||
|
if vendor:
|
||||||
|
vendors[vendor.uuid] = vendor
|
||||||
|
vendors = sorted(vendors.values(), key=lambda v: v.name)
|
||||||
|
vendor_values = [(vendor.uuid, vendor_handler.render_vendor(vendor))
|
||||||
for vendor in vendors]
|
for vendor in vendors]
|
||||||
if use_buefy:
|
if use_buefy:
|
||||||
form.set_widget('vendor', dfwidget.SelectWidget(values=vendor_values))
|
form.set_widget('vendor', dfwidget.SelectWidget(values=vendor_values))
|
||||||
else:
|
else:
|
||||||
form.set_widget('vendor', forms.widgets.JQuerySelectWidget(values=vendor_values))
|
form.set_widget('vendor', forms.widgets.JQuerySelectWidget(values=vendor_values))
|
||||||
else:
|
else:
|
||||||
vendor_display = ""
|
# user may choose *any* available vendor
|
||||||
if self.request.method == 'POST':
|
use_dropdown = vendor_handler.choice_uses_dropdown()
|
||||||
if self.request.POST.get('vendor'):
|
if use_dropdown:
|
||||||
vendor = self.Session.query(model.Vendor).get(self.request.POST['vendor'])
|
vendors = self.Session.query(model.Vendor)\
|
||||||
if vendor:
|
.order_by(model.Vendor.id)
|
||||||
vendor_display = six.text_type(vendor)
|
vendor_values = [(vendor.uuid, "({}) {}".format(vendor.id, vendor.name))
|
||||||
vendors_url = self.request.route_url('vendors.autocomplete')
|
for vendor in vendors]
|
||||||
form.set_widget('vendor', forms.widgets.JQueryAutocompleteWidget(
|
if use_buefy:
|
||||||
field_display=vendor_display, service_url=vendors_url))
|
form.set_widget('vendor', dfwidget.SelectWidget(values=vendor_values))
|
||||||
|
else:
|
||||||
|
form.set_widget('vendor', forms.widgets.JQuerySelectWidget(values=vendor_values))
|
||||||
|
else:
|
||||||
|
vendor_display = ""
|
||||||
|
if self.request.method == 'POST':
|
||||||
|
if self.request.POST.get('vendor'):
|
||||||
|
vendor = self.Session.query(model.Vendor).get(self.request.POST['vendor'])
|
||||||
|
if vendor:
|
||||||
|
vendor_display = six.text_type(vendor)
|
||||||
|
vendors_url = self.request.route_url('vendors.autocomplete')
|
||||||
|
form.set_widget('vendor', forms.widgets.JQueryAutocompleteWidget(
|
||||||
|
field_display=vendor_display, service_url=vendors_url))
|
||||||
form.set_validator('vendor', self.valid_vendor_uuid)
|
form.set_validator('vendor', self.valid_vendor_uuid)
|
||||||
|
|
||||||
# configure workflow field
|
# configure workflow field
|
||||||
|
@ -1876,7 +1894,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
config = self.rattail_config
|
config = self.rattail_config
|
||||||
return [
|
return [
|
||||||
|
|
||||||
# supported workflows
|
# workflows
|
||||||
{'section': 'rattail.batch',
|
{'section': 'rattail.batch',
|
||||||
'option': 'purchase.allow_receiving_from_scratch',
|
'option': 'purchase.allow_receiving_from_scratch',
|
||||||
'type': bool},
|
'type': bool},
|
||||||
|
@ -1893,6 +1911,11 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
'option': 'purchase.allow_truck_dump_receiving',
|
'option': 'purchase.allow_truck_dump_receiving',
|
||||||
'type': bool},
|
'type': bool},
|
||||||
|
|
||||||
|
# vendors
|
||||||
|
{'section': 'rattail.batch',
|
||||||
|
'option': 'purchase.supported_vendors_only',
|
||||||
|
'type': bool},
|
||||||
|
|
||||||
# display
|
# display
|
||||||
{'section': 'rattail.batch',
|
{'section': 'rattail.batch',
|
||||||
'option': 'purchase.receiving.show_ordered_column_in_grid',
|
'option': 'purchase.receiving.show_ordered_column_in_grid',
|
||||||
|
|
Loading…
Reference in a new issue