Share some code for validating vendor field

and add validation for new Ordering batch
This commit is contained in:
Lance Edgar 2023-05-30 13:25:20 -05:00
parent 0d9a502801
commit b4816c6289
3 changed files with 8 additions and 13 deletions

View file

@ -277,6 +277,7 @@ 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))
f.set_validator('vendor_uuid', self.valid_vendor_uuid)
elif self.editing:
f.set_readonly('vendor')
@ -395,12 +396,6 @@ class PurchasingBatchView(BatchMasterView):
'vendor_contact',
'status_code')
def valid_vendor_uuid(self, node, value):
model = self.model
vendor = self.Session.get(model.Vendor, value)
if not vendor:
raise colander.Invalid(node, "Invalid vendor selection")
def render_store(self, batch, field):
store = batch.store
if not store: