-
Notifications
You must be signed in to change notification settings - Fork 36
[FIX] account_statement_import_sheet_file_bg: handle OpenPyXL Cell values in sheet header parsing #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] account_statement_import_sheet_file_bg: handle OpenPyXL Cell values in sheet header parsing #395
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| from . import account_statement_import | ||
| from . import account_statement_import_sheet_parser |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Copyright 2026 ADHOC SA | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import api, models | ||
|
|
||
|
|
||
| class AccountStatementImportSheetParser(models.TransientModel): | ||
| _inherit = "account.statement.import.sheet.parser" | ||
|
|
||
| @api.model | ||
| def parse_header(self, csv_or_xlsx, mapping): | ||
| if mapping.no_header: | ||
| return [] | ||
|
|
||
| header_line = mapping.header_lines_skip_count | ||
| # Prevent negative indexes. | ||
| if header_line > 0: | ||
| header_line -= 1 | ||
|
|
||
| if isinstance(csv_or_xlsx, tuple): | ||
| return super().parse_header(csv_or_xlsx, mapping) | ||
|
|
||
| [next(csv_or_xlsx) for _i in range(header_line)] | ||
| header = [] | ||
| for value in next(csv_or_xlsx): | ||
| raw_value = value.value if hasattr(value, "value") else value | ||
| header.append(str(raw_value).strip() if raw_value is not None else "") | ||
|
Comment on lines
+23
to
+27
|
||
|
|
||
| if mapping.offset_column: | ||
| header = header[mapping.offset_column :] | ||
| return header | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Para XLSX, en vez de iterar
input_worksheet.rowsy extraercell.valuemanualmente, se puede usarinput_worksheet.iter_rows(values_only=True)(y opcionalmente filtrar filas totalmente vacías como en CSV) para reducir overhead/memoria en archivos grandes y mantener el comportamiento más consistente.