Refactor usage of get_vendor() lookup

This commit is contained in:
Lance Edgar 2022-08-13 23:59:09 -05:00
parent 2f5de67ee7
commit f2c73acd3b
2 changed files with 5 additions and 8 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -28,7 +28,7 @@ from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model, api
from rattail.db import model
from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser
# import formalchemy
@ -172,8 +172,10 @@ class VendorInvoiceView(FileBatchMasterView):
return kwargs
def init_batch(self, batch):
app = self.get_rattail_app()
vendor_handler = app.get_vendor_handler()
parser = require_invoice_parser(self.rattail_config, batch.parser_key)
vendor = api.get_vendor(self.Session(), parser.vendor_key)
vendor = vendor_handler.get_vendor(self.Session(), parser.vendor_key)
if not vendor:
self.request.session.flash("No vendor setting found in database for key: {}".format(parser.vendor_key))
return False

View file

@ -476,11 +476,6 @@ class PurchasingBatchView(BatchMasterView):
return [(v.uuid, "({}) {}".format(v.id, v.name))
for v in vendors]
def get_vendor_values(self):
vendors = self.get_vendors()
return [(v.uuid, "({}) {}".format(v.id, v.name))
for v in vendors]
def get_buyers(self):
return self.Session.query(model.Employee)\
.join(model.Person)\