mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG] ofx from v12 to v13
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
'name': 'Import OFX Bank Statement',
|
||||
'category': 'Banking addons',
|
||||
'version': '12.0.1.1.0',
|
||||
'version': '13.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'Odoo SA,'
|
||||
'Akretion,'
|
||||
@@ -10,7 +10,7 @@
|
||||
'Nicolas JEUDY,'
|
||||
'Le Filament,'
|
||||
'Odoo Community Association (OCA)',
|
||||
'website': 'https://odoo-community.org/',
|
||||
'website': 'https://github.com/OCA/bank-statement-import',
|
||||
'depends': [
|
||||
'account_bank_statement_import',
|
||||
],
|
||||
|
||||
@@ -7,8 +7,6 @@ class AccountJournal(models.Model):
|
||||
def _get_bank_statements_available_import_formats(self):
|
||||
""" Adds ofx to supported import formats.
|
||||
"""
|
||||
rslt = super(
|
||||
AccountJournal,
|
||||
self)._get_bank_statements_available_import_formats()
|
||||
rslt = super()._get_bank_statements_available_import_formats()
|
||||
rslt.append('ofx')
|
||||
return rslt
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
* Odoo SA
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
* Laurent Mignon <laurent.mignon@acsone.eu>
|
||||
* Ronald Portier <rportier@therp.nl>
|
||||
* Sylvain LE GAL <https://twitter.com/legalsylvain>
|
||||
* Nicolas JEUDY <https://github.com/njeudy>
|
||||
* Le Filament <https://github.com/lefilament>
|
||||
4
account_bank_statement_import_ofx/readme/DESCRIPTION.rst
Normal file
4
account_bank_statement_import_ofx/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
This module adds support for the import of bank statements in `OFX format <https://en.wikipedia.org/wiki/Open_Financial_Exchange>`_.
|
||||
|
||||
Bank Statements may be generated containing a subset of the OFX information (only those transaction lines that are required for the
|
||||
creation of the Financial Accounting records).
|
||||
1
account_bank_statement_import_ofx/readme/INSTALL.rst
Normal file
1
account_bank_statement_import_ofx/readme/INSTALL.rst
Normal file
@@ -0,0 +1 @@
|
||||
This module requires the `ofxparse <https://pypi.org/project/ofxparse/>`_ python lib.
|
||||
@@ -15,6 +15,7 @@ class TestOfxFile(TransactionCase):
|
||||
self.abs_model = self.env['account.bank.statement']
|
||||
self.j_model = self.env['account.journal']
|
||||
self.absl_model = self.env['account.bank.statement.line']
|
||||
self.ia_model = self.env['ir.attachment']
|
||||
cur = self.env.ref('base.USD')
|
||||
self.env.ref('base.main_company').currency_id = cur.id
|
||||
bank = self.env['res.partner.bank'].create({
|
||||
@@ -49,8 +50,12 @@ class TestOfxFile(TransactionCase):
|
||||
'account_bank_statement_import_ofx',
|
||||
'tests/test_ofx_file/', 'test_ofx_wrong.ofx')
|
||||
ofx_file_wrong = base64.b64encode(open(ofx_file_path, 'rb').read())
|
||||
attach = self.ia_model.create({
|
||||
'name': 'test_ofx_wrong.ofx',
|
||||
'datas': ofx_file_wrong,
|
||||
})
|
||||
bank_statement = self.absi_model.create(
|
||||
dict(data_file=ofx_file_wrong))
|
||||
dict(attachment_ids=[(6, 0, [attach.id])]))
|
||||
self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong))
|
||||
|
||||
def test_ofx_file_import(self):
|
||||
@@ -58,8 +63,12 @@ class TestOfxFile(TransactionCase):
|
||||
'account_bank_statement_import_ofx',
|
||||
'tests/test_ofx_file/', 'test_ofx.ofx')
|
||||
ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read())
|
||||
attach = self.ia_model.create({
|
||||
'name': 'test_ofx.ofx',
|
||||
'datas': ofx_file,
|
||||
})
|
||||
bank_statement = self.absi_model.create(
|
||||
dict(data_file=ofx_file))
|
||||
dict(attachment_ids=[(6, 0, [attach.id])]))
|
||||
bank_statement.import_file()
|
||||
bank_st_record = self.abs_model.search(
|
||||
[('name', 'like', '123456')])[0]
|
||||
@@ -77,8 +86,12 @@ class TestOfxFile(TransactionCase):
|
||||
'account_bank_statement_import_ofx',
|
||||
'tests/test_ofx_file/', 'test_ofx_iban.ofx')
|
||||
ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read())
|
||||
attach = self.ia_model.create({
|
||||
'name': 'test_ofx.ofx',
|
||||
'datas': ofx_file,
|
||||
})
|
||||
bank_st = self.absi_model.create(
|
||||
dict(data_file=ofx_file))
|
||||
dict(attachment_ids=[(6, 0, [attach.id])]))
|
||||
journal_iban_ofx = self.j_model.search([
|
||||
('name', '=', 'FR7630001007941234567890185')])
|
||||
res = bank_st._check_journal_bank_account(journal_iban_ofx,
|
||||
|
||||
@@ -19,9 +19,7 @@ class AccountBankStatementImport(models.TransientModel):
|
||||
_inherit = 'account.bank.statement.import'
|
||||
|
||||
def _check_journal_bank_account(self, journal, account_number):
|
||||
res = super(
|
||||
AccountBankStatementImport, self
|
||||
)._check_journal_bank_account(journal, account_number)
|
||||
res = super()._check_journal_bank_account(journal, account_number)
|
||||
if not res:
|
||||
e_acc_num = journal.bank_account_id.sanitized_acc_number
|
||||
e_acc_num = e_acc_num.replace(" ", "")
|
||||
@@ -70,8 +68,7 @@ class AccountBankStatementImport(models.TransientModel):
|
||||
def _parse_file(self, data_file):
|
||||
ofx = self._check_ofx(data_file)
|
||||
if not ofx:
|
||||
return super(AccountBankStatementImport, self)._parse_file(
|
||||
data_file)
|
||||
return super()._parse_file(data_file)
|
||||
|
||||
transactions = []
|
||||
total_amt = 0.00
|
||||
|
||||
Reference in New Issue
Block a user