From 8a21fe7cfcbca83430fd86d5b73e2951434e6d49 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 21 Mar 2015 17:25:02 -0500 Subject: [PATCH] Fix vendor invoice validation bug. If user provided a PO number but no parser, an error was raised. --- tailbone/views/vendors/invoices.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)