diff --git a/account_statement_import_sheet_file/i18n/es.po b/account_statement_import_sheet_file/i18n/es.po index 380e7d3996..0d3df2c4ad 100644 --- a/account_statement_import_sheet_file/i18n/es.po +++ b/account_statement_import_sheet_file/i18n/es.po @@ -246,8 +246,8 @@ msgstr "Recuento de líneas omitidas a pie de página" #. module: account_statement_import_sheet_file #: model:ir.model.fields,field_description:account_statement_import_sheet_file.field_account_statement_import_sheet_mapping__header_lines_skip_count -msgid "Header lines skip count" -msgstr "Recuento de líneas de cabecera omitidas" +msgid "Header row number" +msgstr "Número de fila del encabezado" #. module: account_statement_import_sheet_file #: model:ir.model.fields,field_description:account_statement_import_sheet_file.field_account_statement_import_sheet_mapping__id @@ -403,8 +403,8 @@ msgstr "" #. module: account_statement_import_sheet_file #: model:ir.model.fields,help:account_statement_import_sheet_file.field_account_statement_import_sheet_mapping__header_lines_skip_count -msgid "Set the Header lines number." -msgstr "Establezca el número de líneas de Cabecera." +msgid "Row number where the column headers are located (first row is 0)." +msgstr "Número de fila donde se encuentran los encabezados de columna (la primera fila es 0)." #. module: account_statement_import_sheet_file #: model:ir.model.fields,field_description:account_statement_import_sheet_file.field_account_statement_import__sheet_mapping_id diff --git a/account_statement_import_sheet_file/models/account_statement_import_sheet_mapping.py b/account_statement_import_sheet_file/models/account_statement_import_sheet_mapping.py index 8ca187f525..9da4785538 100644 --- a/account_statement_import_sheet_file/models/account_statement_import_sheet_mapping.py +++ b/account_statement_import_sheet_file/models/account_statement_import_sheet_mapping.py @@ -77,9 +77,6 @@ class AccountStatementImportSheetMapping(models.Model): "transaction from" ), ) - amount_column = fields.Char( - help="Amount of transaction in journal's currency", - ) amount_debit_column = fields.Char( string="Debit amount column", help="Debit amount of transaction in journal's currency", @@ -122,7 +119,7 @@ class AccountStatementImportSheetMapping(models.Model): required=True, default="simple_value", help=( - "Simple value: use igned amount in amount column\n" + "Simple value: use signed amount in amount column\n" "Absolute Value: use a same column for debit and credit\n" "(absolute value + indicate sign)\n" "Distinct Credit/debit Column: use a distinct column for debit and credit" @@ -173,8 +170,8 @@ class AccountStatementImportSheetMapping(models.Model): default="0", ) header_lines_skip_count = fields.Integer( - string="Header lines skip count", - help="Set the Header lines number.", + string="Header row number", + help="Row number where the column headers are located (first row is 0).", default="0", ) skip_empty_lines = fields.Boolean( @@ -232,6 +229,13 @@ def onchange_decimal_separator(self): elif "comma" == self.float_thousands_sep == self.float_decimal_sep: self.float_thousands_sep = "dot" + @api.onchange("amount_type") + def _clear_amount_columns(self): + self.amount_column = False + self.debit_credit_column = False + self.amount_debit_column = False + self.amount_credit_column = False + @api.constrains("offset_column") def _check_columns(self): for mapping in self: diff --git a/account_statement_import_sheet_file/wizard/account_statement_import_sheet_parser.py b/account_statement_import_sheet_file/wizard/account_statement_import_sheet_parser.py index c6c8c36d32..5bf149ddaa 100644 --- a/account_statement_import_sheet_file/wizard/account_statement_import_sheet_parser.py +++ b/account_statement_import_sheet_file/wizard/account_statement_import_sheet_parser.py @@ -144,7 +144,22 @@ def _get_column_indexes(self, header, column_name, mapping): column_indexes.append(column_index) else: if column_name_or_index: - column_indexes.append(header.index(column_name_or_index)) + try: + column_indexes.append(header.index(column_name_or_index)) + except ValueError: + # Fallback: case-insensitive match + column_index = next( + ( + i + for i, h in enumerate(header) + if str(h).lower() == column_name_or_index.lower() + ), + None, + ) + if column_index is not None: + column_indexes.append(column_index) + else: + raise return column_indexes def _get_column_names(self): @@ -403,6 +418,8 @@ def _parse_decimal(self, value, mapping): return float(value) elif isinstance(value, float): return value + if not isinstance(value, str): + value = str(value) thousands, decimal = mapping._get_float_separators() # Remove all characters except digits, thousands separator, # decimal separator, and signs