diff --git a/account_bank_statement_import_txt_xlsx/__manifest__.py b/account_bank_statement_import_txt_xlsx/__manifest__.py index 6d1f50c..d4de2e9 100644 --- a/account_bank_statement_import_txt_xlsx/__manifest__.py +++ b/account_bank_statement_import_txt_xlsx/__manifest__.py @@ -30,6 +30,7 @@ "data/map_data.xml", "views/account_bank_statement_import_sheet_mapping.xml", "views/account_bank_statement_import.xml", + "views/account_journal_views.xml", "wizards/account_bank_statement_import_sheet_mapping_wizard.xml", ] } diff --git a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import.py b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import.py index dd869e9..a872418 100644 --- a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import.py +++ b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import.py @@ -10,9 +10,14 @@ _logger = logging.getLogger(__name__) class AccountBankStatementImport(models.TransientModel): _inherit = 'account.bank.statement.import' + def _get_default_mapping_id(self): + return self.env["account.journal"].browse( + self.env.context.get('journal_id')).default_sheet_mapping_id + sheet_mapping_id = fields.Many2one( string='Sheet mapping', comodel_name='account.bank.statement.import.sheet.mapping', + default=_get_default_mapping_id, ) @api.multi diff --git a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py index 8925784..fb05601 100644 --- a/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py +++ b/account_bank_statement_import_txt_xlsx/models/account_bank_statement_import_sheet_parser.py @@ -117,7 +117,7 @@ class AccountBankStatementImportSheetParser(models.TransientModel): if isinstance(csv_or_xlsx, tuple): header = [str(value) for value in csv_or_xlsx[1].row_values(0)] else: - header = list(next(csv_or_xlsx)) + header = [value.strip() for value in next(csv_or_xlsx)] timestamp_column = header.index(mapping.timestamp_column) currency_column = header.index(mapping.currency_column) \ if mapping.currency_column else None diff --git a/account_bank_statement_import_txt_xlsx/models/account_journal.py b/account_bank_statement_import_txt_xlsx/models/account_journal.py index 9281be0..8d90643 100644 --- a/account_bank_statement_import_txt_xlsx/models/account_journal.py +++ b/account_bank_statement_import_txt_xlsx/models/account_journal.py @@ -2,12 +2,16 @@ # Copyright 2020 Brainbean Apps (https://brainbeanapps.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import models +from odoo import fields, models class AccountJournal(models.Model): _inherit = 'account.journal' + default_sheet_mapping_id = fields.Many2one( + comodel_name='account.bank.statement.import.sheet.mapping', + ) + def _get_bank_statements_available_import_formats(self): res = super()._get_bank_statements_available_import_formats() res.append('TXT/CSV/XSLX') diff --git a/account_bank_statement_import_txt_xlsx/views/account_journal_views.xml b/account_bank_statement_import_txt_xlsx/views/account_journal_views.xml new file mode 100644 index 0000000..2686519 --- /dev/null +++ b/account_bank_statement_import_txt_xlsx/views/account_journal_views.xml @@ -0,0 +1,16 @@ + + + + + account.journal + + + + + + + + + + +