Misc. improvements for ordering batches, purchases

also we now show handler's description when executing batch
This commit is contained in:
Lance Edgar 2021-01-30 13:17:08 -06:00
parent e1e3301fc1
commit fac00e6ecd
8 changed files with 77 additions and 34 deletions

View file

@ -281,9 +281,9 @@ class PurchasingBatchView(BatchMasterView):
if self.creating:
f.replace('vendor', 'vendor_uuid')
f.set_label('vendor_uuid', "Vendor")
widget_type = self.rattail_config.get('tailbone', 'default_widget.vendor',
default='autocomplete')
if widget_type == 'autocomplete':
use_autocomplete = self.rattail_config.getbool(
'rattail', 'vendor.use_autocomplete', default=True)
if use_autocomplete:
vendor_display = ""
if self.request.method == 'POST':
if self.request.POST.get('vendor_uuid'):
@ -293,14 +293,12 @@ class PurchasingBatchView(BatchMasterView):
vendors_url = self.request.route_url('vendors.autocomplete')
f.set_widget('vendor_uuid', forms.widgets.JQueryAutocompleteWidget(
field_display=vendor_display, service_url=vendors_url))
elif widget_type == 'dropdown':
else:
vendors = self.Session.query(model.Vendor)\
.order_by(model.Vendor.id)
vendor_values = [(vendor.uuid, "({}) {}".format(vendor.id, vendor.name))
for vendor in vendors]
f.set_widget('vendor_uuid', dfwidget.SelectWidget(values=vendor_values))
else:
raise NotImplementedError("Unsupported vendor widget type: {}".format(widget_type))
elif self.editing:
f.set_readonly('vendor')