Fix vendor invoice validation bug.

If user provided a PO number but no parser, an error was raised.
This commit is contained in:
Lance Edgar 2015-03-21 17:25:02 -05:00
parent 366572e0a7
commit 8a21fe7cfc

View file

@ -110,7 +110,10 @@ class VendorInvoiceCrud(FileBatchCrud):
Let the invoice handler in effect determine if the user-provided Let the invoice handler in effect determine if the user-provided
purchase order number is valid. 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) vendor = get_vendor(Session(), parser.vendor_key)
try: try:
self.handler.validate_po_number(value, vendor) self.handler.validate_po_number(value, vendor)