[ADD] account_statement_import_sheet_file_ux: preview the file a mapping expects - #439
Open
feg-adhoc wants to merge 1 commit into
Open
[ADD] account_statement_import_sheet_file_ux: preview the file a mapping expects#439feg-adhoc wants to merge 1 commit into
feg-adhoc wants to merge 1 commit into
Conversation
…ing expects
Most of the support around the statement sheet import comes from mappings
that do not describe the file the bank exports, and the error the user gets
back ('Date' is not in list) says nothing about which part of the mapping is
wrong.
Adds a "Preview Mapping" button on the sheet mapping that renders a sample
sheet, with column letters and row numbers, built from the mapping as it is
configured: where the header row must be, which columns must exist, and how
dates and amounts must be written, with three sample transactions filled in.
The sample can be downloaded as xlsx; every cell is written as text, the way
the parser reads them, so the file can be imported with that very mapping to
check it end to end.
The preview also reads the mapping back in plain words and warns about the
configurations that are going to fail, and a failed import now names the
mapping and the missing column (or the date format that does not match) and
offers a button that opens the mapping.
Carries the remaining fixes as an extension instead of patching the base
module: case and padding insensitive column matching, the decimal cast the
xls parser needs, a clearer name and help for the header row number, and
clearing the amount columns when the amount type changes. Depends on the xls
and xlsx modules and auto installs with the base one, so a database that can
import csv statements can also import spreadsheets.
There was a problem hiding this comment.
Pull request overview
Este PR incorpora el nuevo módulo account_statement_import_sheet_file_ux para mejorar la experiencia de configuración e importación de extractos bancarios en planillas (xls/xlsx), agregando previsualización del archivo esperado, generación de un sample importable y errores de importación más accionables para guiar al usuario hacia la corrección del mapping.
Changes:
- Agrega un wizard de “Mapping preview” que renderiza un sample visual (HTML) y permite descargar un xlsx consistente con el mapping.
- Mejora la importación: ante fallas de parseo, eleva un
RedirectWarningcon contexto (mapping/columna/formato) y acceso directo al mapping. - Ajusta el comportamiento del parser y del mapping: matching de columnas case/trim-insensitive, parseo de decimales desde números crudos, rename de “header lines skip count” a “Header row number”, y limpieza de columnas al cambiar el Amount type.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| account_statement_import_sheet_file_ux/init.py | Inicializa el módulo cargando models y wizard. |
| account_statement_import_sheet_file_ux/manifest.py | Declara el módulo, dependencias y data (vistas + ACL). |
| account_statement_import_sheet_file_ux/README.rst | Documenta funcionalidad, uso y notas técnicas del módulo UX. |
| account_statement_import_sheet_file_ux/i18n/account_statement_import_sheet_file_ux.pot | Template de traducciones para los nuevos textos (Python y QWeb). |
| account_statement_import_sheet_file_ux/security/ir.model.access.csv | ACL para el wizard de preview. |
| account_statement_import_sheet_file_ux/models/init.py | Exporta los overrides del mapping y del parser. |
| account_statement_import_sheet_file_ux/models/account_statement_import_sheet_mapping.py | Implementa preview layout/notes/warnings, botón de preview y mejoras UX del mapping. |
| account_statement_import_sheet_file_ux/models/account_statement_import_sheet_parser.py | Hace el matching de headers case/trim-insensitive y acepta números crudos en _parse_decimal. |
| account_statement_import_sheet_file_ux/wizard/init.py | Registra los wizards nuevos/extendidos. |
| account_statement_import_sheet_file_ux/wizard/account_statement_import.py | Override de _parse_file para re-lanzar errores como RedirectWarning con hint accionable. |
| account_statement_import_sheet_file_ux/wizard/account_statement_import_sheet_mapping_preview.py | Wizard que renderiza el HTML y genera/descarga el xlsx sample. |
| account_statement_import_sheet_file_ux/views/account_statement_import_sheet_mapping_views.xml | Inserta el botón “Preview Mapping” en la vista del mapping. |
| account_statement_import_sheet_file_ux/views/account_statement_import_sheet_mapping_preview_views.xml | QWeb template del preview + vista form del wizard con botón de descarga. |
| account_statement_import_sheet_file_ux/tests/init.py | Habilita la carga del suite de tests del módulo. |
| account_statement_import_sheet_file_ux/tests/test_mapping_preview.py | Cobertura de preview/layout, sample importable, parser fixes y RedirectWarning en imports fallidos. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Most of the support around the statement sheet import comes from mappings that do not describe the file the bank exports: a renamed header, a header row on the wrong line, the thousands separator the other way around. The error the user gets back (
'Date' is not in list) says nothing about which part of the mapping is wrong.Rather than keep patching
account_statement_import_sheet_file, this addsaccount_statement_import_sheet_file_ux, which auto installs with it.What it adds
Preview Mappingbutton on the sheet mapping. Renders a sample sheet — column letters, row numbers, header in bold, ignored rows greyed out — built from the mapping as it is configured right now, with three sample transactions filled in so the layout is unambiguous.0(the spreadsheet parser then reads the header row as a transaction too and the import fails), or column names on a mapping declared as having no header line.RedirectWarningthat keeps the original error, names the mapping and the column that is missing (or the date format that does not match), and offers a button that opens the mapping.DATEone month andDatethe next does not break the import.Header lines skip countis renamed toHeader row numberwith a help that explains what the number means, and the amount columns are cleared when the Amount type changes.Notes on the approach
max(header_lines_skip_count, 1)and the transactions start right afterheader_lines_skip_count._get_column_indexesrewrites the header cells that match a configured name to the configured spelling and delegates to the standard lookup, instead of duplicating it. An unknown column still raises.auto_installtriggered by the base one, so a database that can import csv statements can also import spreadsheets.Test plan
17 tests, all green:
0,1,2and5, and0produces the warning.no_headerwith indexes,no_headermisconfigured with names, thenonedecimal separator and the inverse sign all render the expected cells.Manual check pending in runbot for the visual side (button placement and modal rendering).
Task: https://www.adhoc.inc/odoo/project.task/71587