diff --git a/tailbone/views/vendors/invoices.py b/tailbone/views/vendors/invoices.py index 8293c2c9..2bd9e624 100644 --- a/tailbone/views/vendors/invoices.py +++ b/tailbone/views/vendors/invoices.py @@ -110,7 +110,10 @@ class VendorInvoiceCrud(FileBatchCrud): Let the invoice handler in effect determine if the user-provided purchase order number is valid. """ - parser = require_invoice_parser(field.parent.parser_key.value) + parser_key = field.parent.parser_key.value + if not parser_key: + raise formalchemy.ValidationError("Cannot validate PO number until File Type is chosen") + parser = require_invoice_parser(parser_key) vendor = get_vendor(Session(), parser.vendor_key) try: self.handler.validate_po_number(value, vendor)