Assume default vendor for new receiving batch

i.e. if there is only one vendor
This commit is contained in:
Lance Edgar 2022-07-24 15:05:51 -05:00
parent 25f39f4173
commit 0dc344b821

View file

@ -332,13 +332,16 @@ class ReceivingBatchView(PurchasingBatchView):
use_dropdown = vendor_handler.choice_uses_dropdown()
if use_dropdown:
vendors = self.Session.query(model.Vendor)\
.order_by(model.Vendor.id)
.order_by(model.Vendor.id)\
.all()
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))
if len(vendors) == 1:
form.set_default('vendor', vendors[0].uuid)
else:
vendor_display = ""
if self.request.method == 'POST':