diff --git a/rattail/importing/files.py b/rattail/importing/files.py index ef03ce1c..ae0f6009 100644 --- a/rattail/importing/files.py +++ b/rattail/importing/files.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import import os from rattail import importing -from rattail.excel import ExcelReader +from rattail.excel import ExcelReaderXLS, ExcelReaderXLSX class FromFile(importing.Importer): @@ -68,7 +68,10 @@ class FromExcelFile(FromFile): return '{}.xlsx'.format(self.model_name) def open_input_file(self): - self.excel_reader = ExcelReader(self.input_file_path) + if self.input_file_path.endswith('.xls'): + self.excel_reader = ExcelReaderXLS(self.input_file_path) + else: + self.excel_reader = ExcelReaderXLSX(self.input_file_path) def close_input_file(self): pass diff --git a/rattail/importing/importers.py b/rattail/importing/importers.py index fd5ef8dd..79af5be2 100644 --- a/rattail/importing/importers.py +++ b/rattail/importing/importers.py @@ -229,6 +229,13 @@ class Importer(object): end_time = datetime.datetime.combine(end_date, datetime.time(0)) self.end_time = self.app.localtime(end_time) + # and some commands use --year instead of date range + if not hasattr(self, 'year') or not self.year: + if hasattr(self, 'args') and hasattr(self.args, 'year'): + self.year = self.args.year + else: + self.year = None + def setup(self): """ Perform any setup necessary, e.g. cache lookups for existing data.