Fix vendor ID/name for Excel download of pricing batch rows

This commit is contained in:
Lance Edgar 2020-01-28 16:33:23 -06:00
parent b875540397
commit 132b2b9ec7

View file

@ -261,6 +261,7 @@ class PricingBatchView(BatchMasterView):
return fields return fields
# TODO: this is the same as xlsx row! should merge/share somehow?
def get_row_csv_row(self, row, fields): def get_row_csv_row(self, row, fields):
csvrow = super(PricingBatchView, self).get_row_csv_row(row, fields) csvrow = super(PricingBatchView, self).get_row_csv_row(row, fields)
@ -274,6 +275,20 @@ class PricingBatchView(BatchMasterView):
return csvrow return csvrow
# TODO: this is the same as csv row! should merge/share somehow?
def get_row_xlsx_row(self, row, fields):
xlrow = super(PricingBatchView, self).get_row_xlsx_row(row, fields)
vendor = row.vendor
if 'vendor_id' in fields:
xlrow['vendor_id'] = (vendor.id or '') if vendor else ''
if 'vendor_abbreviation' in fields:
xlrow['vendor_abbreviation'] = (vendor.abbreviation or '') if vendor else ''
if 'vendor_name' in fields:
xlrow['vendor_name'] = (vendor.name or '') if vendor else ''
return xlrow
def includeme(config): def includeme(config):
PricingBatchView.defaults(config) PricingBatchView.defaults(config)