Browse Source

Merge PR #272 into 12.0

Signed-off-by alexey-pelykh
12.0
OCA-git-bot 5 years ago
parent
commit
3fd9c2be40
  1. 20
      account_bank_statement_import_online/models/online_bank_statement_provider.py
  2. 2
      account_bank_statement_import_online/tests/online_bank_statement_provider_dummy.py

20
account_bank_statement_import_online/models/online_bank_statement_provider.py

@ -41,7 +41,7 @@ class OnlineBankStatementProvider(models.Model):
related='journal_id.currency_id', related='journal_id.currency_id',
) )
account_number = fields.Char( account_number = fields.Char(
related='journal_id.bank_account_id.acc_number'
related='journal_id.bank_account_id.sanitized_acc_number'
) )
service = fields.Selection( service = fields.Selection(
selection=lambda self: self._selection_service(), selection=lambda self: self._selection_service(),
@ -258,6 +258,15 @@ class OnlineBankStatementProvider(models.Model):
[('unique_import_id', '=', unique_import_id)], [('unique_import_id', '=', unique_import_id)],
limit=1): limit=1):
continue 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) filtered_lines.append(line_values)
statement_values.update({ statement_values.update({
'line_ids': [[0, False, line] for line in filtered_lines], 'line_ids': [[0, False, line] for line in filtered_lines],
@ -340,11 +349,16 @@ class OnlineBankStatementProvider(models.Model):
@api.multi @api.multi
def _generate_unique_import_id(self, unique_import_id): def _generate_unique_import_id(self, unique_import_id):
self.ensure_one() self.ensure_one()
sanitized_account_number = sanitize_account_number(self.account_number)
return ( 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 ) + 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 @api.multi
def _get_next_run_period(self): def _get_next_run_period(self):
self.ensure_one() self.ensure_one()

2
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( 'unique_import_id': str(int(
(date - datetime(1970, 1, 1)) / timedelta(seconds=1) (date - datetime(1970, 1, 1)) / timedelta(seconds=1)
)), )),
'partner_name': 'John Doe',
'account_number': 'XX00 0000 0000 0000',
}) })
balance += amount balance += amount
date += line_step date += line_step

Loading…
Cancel
Save