+ Vendors
+
+
+
+
+ Only allow batch for "supported" vendors
+
+
+
+
+
Display
diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py
index 20f70e5d..bca9ef64 100644
--- a/tailbone/views/purchasing/receiving.py
+++ b/tailbone/views/purchasing/receiving.py
@@ -311,26 +311,44 @@ class ReceivingBatchView(PurchasingBatchView):
# configure vendor field
app = self.get_rattail_app()
vendor_handler = app.get_vendor_handler()
- use_dropdown = vendor_handler.choice_uses_dropdown()
- if use_dropdown:
- vendors = self.Session.query(model.Vendor)\
- .order_by(model.Vendor.id)
- vendor_values = [(vendor.uuid, "({}) {}".format(vendor.id, vendor.name))
+ if self.rattail_config.getbool('rattail.batch', 'purchase.supported_vendors_only'):
+ # only show vendors for which we have dedicated invoice parsers
+ vendors = {}
+ for parser in self.batch_handler.get_supported_invoice_parsers():
+ 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]
if use_buefy:
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))
+ # user may choose *any* available vendor
+ use_dropdown = vendor_handler.choice_uses_dropdown()
+ if use_dropdown:
+ vendors = self.Session.query(model.Vendor)\
+ .order_by(model.Vendor.id)
+ vendor_values = [(vendor.uuid, "({}) {}".format(vendor.id, vendor.name))
+ for vendor in vendors]
+ if use_buefy:
+ 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)
# configure workflow field
@@ -1876,7 +1894,7 @@ class ReceivingBatchView(PurchasingBatchView):
config = self.rattail_config
return [
- # supported workflows
+ # workflows
{'section': 'rattail.batch',
'option': 'purchase.allow_receiving_from_scratch',
'type': bool},
@@ -1893,6 +1911,11 @@ class ReceivingBatchView(PurchasingBatchView):
'option': 'purchase.allow_truck_dump_receiving',
'type': bool},
+ # vendors
+ {'section': 'rattail.batch',
+ 'option': 'purchase.supported_vendors_only',
+ 'type': bool},
+
# display
{'section': 'rattail.batch',
'option': 'purchase.receiving.show_ordered_column_in_grid',