From bb47930f74de1be659d5f93171dfdc4bef5f3f21 Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Mon, 13 Jan 2025 09:10:32 -0500 Subject: [PATCH] [FIX] account_statement_import_sheet_file: Prevent negative index in parser header When importing an Excel file with a header and the field header_lines_skip_count is set to its default value (0), the header is retrieved using the -1 index (the last row). complementary to commit https://github.com/OCA/bank-statement-import/commit/13285abe74d326153c8d0e74c21ddbdf3cdf17a0 --- .../models/account_statement_import_sheet_parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py b/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py index a9be621d..7062f6ae 100644 --- a/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py +++ b/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py @@ -179,7 +179,10 @@ class AccountStatementImportSheetParser(models.TransientModel): csv_or_xlsx = reader(StringIO(decoded_file), **csv_options) header = False if not mapping.no_header: - header_line = mapping.header_lines_skip_count - 1 + header_line = mapping.header_lines_skip_count + # prevent negative indexes + if header_line > 0: + header_line -= 1 if isinstance(csv_or_xlsx, tuple): header = [ str(value).strip()