[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 13285abe74
This commit is contained in:
Carlos Lopez
2025-01-13 09:10:32 -05:00
parent 2298d49c08
commit bb47930f74

View File

@@ -179,7 +179,10 @@ class AccountStatementImportSheetParser(models.TransientModel):
csv_or_xlsx = reader(StringIO(decoded_file), **csv_options) csv_or_xlsx = reader(StringIO(decoded_file), **csv_options)
header = False header = False
if not mapping.no_header: 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): if isinstance(csv_or_xlsx, tuple):
header = [ header = [
str(value).strip() str(value).strip()