Skip to content

Commit

Permalink
[MIG] account_statement_import_ofx: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-filament committed Dec 9, 2024
1 parent b10d5e8 commit c5c9704
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
4 changes: 2 additions & 2 deletions account_statement_import_ofx/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Import OFX Bank Statement",
"category": "Banking addons",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Odoo SA,"
"Akretion,"
Expand All @@ -14,7 +14,7 @@
"development_status": "Mature",
"website": "https://github.com/OCA/bank-statement-import",
"depends": ["account_statement_import_file"],
"data": ["views/account_statement_import.xml"],
"data": ["wizard/account_statement_import.xml"],
"external_dependencies": {"python": ["ofxparse"]},
"installable": True,
}
59 changes: 26 additions & 33 deletions account_statement_import_ofx/tests/test_import_bank_statement.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import base64
import datetime

from odoo.modules.module import get_module_resource
from odoo.tests.common import TransactionCase
import odoo.tests.common as common
from odoo.tools.misc import file_path


class TestOfxFile(TransactionCase):
class TestOfxFile(common.TransactionCase):
"""Tests for import bank statement ofx file format
(account.bank.statement.import)
"""

def setUp(self):
super(TestOfxFile, self).setUp()
self.asi_model = self.env["account.statement.import"]
self.abs_model = self.env["account.bank.statement"]
self.j_model = self.env["account.journal"]
self.absl_model = self.env["account.bank.statement.line"]
cur = self.env.ref("base.USD")
# self.env.ref("base.main_company").currency_id = cur.id
bank = self.env["res.partner.bank"].create(
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.asi_model = cls.env["account.statement.import"]
cls.abs_model = cls.env["account.bank.statement"]
cls.absl_model = cls.env["account.bank.statement.line"]
cur = cls.env.ref("base.USD")
bank = cls.env["res.partner.bank"].create(
{
"acc_number": "123456",
"partner_id": self.env.ref("base.main_partner").id,
"company_id": self.env.ref("base.main_company").id,
"bank_id": self.env.ref("base.res_bank_1").id,
"partner_id": cls.env.ref("base.main_partner").id,
"company_id": cls.env.ref("base.main_company").id,
"bank_id": cls.env.ref("base.res_bank_1").id,
}
)
self.env["account.journal"].create(
cls.env["account.journal"].create(
{
"name": "Bank Journal TEST OFX",
"code": "BNK12",
Expand All @@ -35,17 +34,15 @@ def setUp(self):
"currency_id": cur.id,
}
)

bank_iban_ofx = self.env["res.partner.bank"].create(
bank_iban_ofx = cls.env["res.partner.bank"].create(
{
"acc_number": "FR7630001007941234567890185",
"partner_id": self.env.ref("base.main_partner").id,
"company_id": self.env.ref("base.main_company").id,
"bank_id": self.env.ref("base.res_bank_1").id,
"partner_id": cls.env.ref("base.main_partner").id,
"company_id": cls.env.ref("base.main_company").id,
"bank_id": cls.env.ref("base.res_bank_1").id,
}
)

self.env["account.journal"].create(
cls.env["account.journal"].create(
{
"name": "FR7630001007941234567890185",
"code": "BNK13",
Expand All @@ -56,10 +53,8 @@ def setUp(self):
)

def test_wrong_ofx_file_import(self):
ofx_file_path = get_module_resource(
"account_statement_import_ofx",
"tests/test_ofx_file/",
"test_ofx_wrong.ofx",
ofx_file_path = file_path(
"account_statement_import_ofx/tests/test_ofx_file/test_ofx_wrong.ofx"
)
ofx_file_wrong = base64.b64encode(open(ofx_file_path, "rb").read())
bank_statement = self.asi_model.create(
Expand All @@ -71,8 +66,8 @@ def test_wrong_ofx_file_import(self):
self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong))

def test_ofx_file_import(self):
ofx_file_path = get_module_resource(
"account_statement_import_ofx", "tests/test_ofx_file/", "test_ofx.ofx"
ofx_file_path = file_path(
"account_statement_import_ofx/tests/test_ofx_file/test_ofx.ofx"
)
ofx_file = base64.b64encode(open(ofx_file_path, "rb").read())
bank_statement = self.asi_model.create(
Expand All @@ -95,10 +90,8 @@ def test_ofx_file_import(self):
self.assertEqual(line.date, datetime.date(2013, 8, 24))

def test_check_journal_bank_account(self):
ofx_file_path = get_module_resource(
"account_statement_import_ofx",
"tests/test_ofx_file/",
"test_ofx_iban.ofx",
ofx_file_path = file_path(
"account_statement_import_ofx/tests/test_ofx_file/test_ofx_iban.ofx"
)
ofx_file = base64.b64encode(open(ofx_file_path, "rb").read())
bank_st = self.asi_model.create(
Expand Down

0 comments on commit c5c9704

Please sign in to comment.