diff --git a/account_bank_statement_import_online/models/online_bank_statement_provider.py b/account_bank_statement_import_online/models/online_bank_statement_provider.py index 41001f3..30670fd 100644 --- a/account_bank_statement_import_online/models/online_bank_statement_provider.py +++ b/account_bank_statement_import_online/models/online_bank_statement_provider.py @@ -41,7 +41,7 @@ class OnlineBankStatementProvider(models.Model): related='journal_id.currency_id', ) account_number = fields.Char( - related='journal_id.bank_account_id.acc_number' + related='journal_id.bank_account_id.sanitized_acc_number' ) service = fields.Selection( selection=lambda self: self._selection_service(), @@ -258,6 +258,15 @@ class OnlineBankStatementProvider(models.Model): [('unique_import_id', '=', unique_import_id)], limit=1): continue + bank_account_number = line_values.get('account_number') + if bank_account_number: + line_values.update({ + 'account_number': ( + self._sanitize_bank_account_number( + bank_account_number + ) + ), + }) filtered_lines.append(line_values) statement_values.update({ 'line_ids': [[0, False, line] for line in filtered_lines], @@ -340,11 +349,16 @@ class OnlineBankStatementProvider(models.Model): @api.multi def _generate_unique_import_id(self, unique_import_id): self.ensure_one() - sanitized_account_number = sanitize_account_number(self.account_number) return ( - sanitized_account_number and sanitized_account_number + '-' or '' + self.account_number and self.account_number + '-' or '' ) + str(self.journal_id.id) + '-' + unique_import_id + @api.multi + def _sanitize_bank_account_number(self, bank_account_number): + """Hook for extension""" + self.ensure_one() + return sanitize_account_number(bank_account_number) + @api.multi def _get_next_run_period(self): self.ensure_one() diff --git a/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py b/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py index 6c3f087..21732b1 100644 --- a/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py +++ b/account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py @@ -49,6 +49,8 @@ class OnlineBankStatementProviderDummy(models.Model): 'unique_import_id': str(int( (date - datetime(1970, 1, 1)) / timedelta(seconds=1) )), + 'partner_name': 'John Doe', + 'account_number': 'XX00 0000 0000 0000', }) balance += amount date += line_step