Refactor usage of get_vendor()
lookup
This commit is contained in:
parent
2f5de67ee7
commit
f2c73acd3b
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2021 Lance Edgar
|
# Copyright © 2010-2022 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -28,7 +28,7 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from rattail.db import model, api
|
from rattail.db import model
|
||||||
from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser
|
from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser
|
||||||
|
|
||||||
# import formalchemy
|
# import formalchemy
|
||||||
|
@ -172,8 +172,10 @@ class VendorInvoiceView(FileBatchMasterView):
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def init_batch(self, batch):
|
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)
|
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:
|
if not vendor:
|
||||||
self.request.session.flash("No vendor setting found in database for key: {}".format(parser.vendor_key))
|
self.request.session.flash("No vendor setting found in database for key: {}".format(parser.vendor_key))
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -476,11 +476,6 @@ class PurchasingBatchView(BatchMasterView):
|
||||||
return [(v.uuid, "({}) {}".format(v.id, v.name))
|
return [(v.uuid, "({}) {}".format(v.id, v.name))
|
||||||
for v in vendors]
|
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):
|
def get_buyers(self):
|
||||||
return self.Session.query(model.Employee)\
|
return self.Session.query(model.Employee)\
|
||||||
.join(model.Person)\
|
.join(model.Person)\
|
||||||
|
|
Loading…
Reference in a new issue