[MIG] account_statement_import_ofx: Migration to 17.0

This commit is contained in:
Rémi - Le Filament
2024-05-22 09:06:02 +02:00
parent 511ba00c29
commit 3cd63d2748
3 changed files with 28 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "Import OFX Bank Statement", "name": "Import OFX Bank Statement",
"category": "Banking addons", "category": "Banking addons",
"version": "16.0.1.0.0", "version": "17.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Odoo SA," "author": "Odoo SA,"
"Akretion," "Akretion,"
@@ -14,7 +14,7 @@
"development_status": "Mature", "development_status": "Mature",
"website": "https://github.com/OCA/bank-statement-import", "website": "https://github.com/OCA/bank-statement-import",
"depends": ["account_statement_import_file"], "depends": ["account_statement_import_file"],
"data": ["views/account_statement_import.xml"], "data": ["wizard/account_statement_import.xml"],
"external_dependencies": {"python": ["ofxparse"]}, "external_dependencies": {"python": ["ofxparse"]},
"installable": True, "installable": True,
} }

View File

@@ -1,32 +1,31 @@
import base64 import base64
import datetime import datetime
from odoo.modules.module import get_module_resource import odoo.tests.common as common
from odoo.tests.common import TransactionCase from odoo.tools.misc import file_path
class TestOfxFile(TransactionCase): class TestOfxFile(common.TransactionCase):
"""Tests for import bank statement ofx file format """Tests for import bank statement ofx file format
(account.bank.statement.import) (account.bank.statement.import)
""" """
def setUp(self): @classmethod
super(TestOfxFile, self).setUp() def setUpClass(cls):
self.asi_model = self.env["account.statement.import"] super().setUpClass()
self.abs_model = self.env["account.bank.statement"] cls.asi_model = cls.env["account.statement.import"]
self.j_model = self.env["account.journal"] cls.abs_model = cls.env["account.bank.statement"]
self.absl_model = self.env["account.bank.statement.line"] cls.absl_model = cls.env["account.bank.statement.line"]
cur = self.env.ref("base.USD") cur = cls.env.ref("base.USD")
# self.env.ref("base.main_company").currency_id = cur.id bank = cls.env["res.partner.bank"].create(
bank = self.env["res.partner.bank"].create(
{ {
"acc_number": "123456", "acc_number": "123456",
"partner_id": self.env.ref("base.main_partner").id, "partner_id": cls.env.ref("base.main_partner").id,
"company_id": self.env.ref("base.main_company").id, "company_id": cls.env.ref("base.main_company").id,
"bank_id": self.env.ref("base.res_bank_1").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", "name": "Bank Journal TEST OFX",
"code": "BNK12", "code": "BNK12",
@@ -35,17 +34,15 @@ class TestOfxFile(TransactionCase):
"currency_id": cur.id, "currency_id": cur.id,
} }
) )
bank_iban_ofx = cls.env["res.partner.bank"].create(
bank_iban_ofx = self.env["res.partner.bank"].create(
{ {
"acc_number": "FR7630001007941234567890185", "acc_number": "FR7630001007941234567890185",
"partner_id": self.env.ref("base.main_partner").id, "partner_id": cls.env.ref("base.main_partner").id,
"company_id": self.env.ref("base.main_company").id, "company_id": cls.env.ref("base.main_company").id,
"bank_id": self.env.ref("base.res_bank_1").id, "bank_id": cls.env.ref("base.res_bank_1").id,
} }
) )
cls.env["account.journal"].create(
self.env["account.journal"].create(
{ {
"name": "FR7630001007941234567890185", "name": "FR7630001007941234567890185",
"code": "BNK13", "code": "BNK13",
@@ -56,10 +53,8 @@ class TestOfxFile(TransactionCase):
) )
def test_wrong_ofx_file_import(self): def test_wrong_ofx_file_import(self):
ofx_file_path = get_module_resource( ofx_file_path = file_path(
"account_statement_import_ofx", "account_statement_import_ofx/tests/test_ofx_file/test_ofx_wrong.ofx"
"tests/test_ofx_file/",
"test_ofx_wrong.ofx",
) )
ofx_file_wrong = base64.b64encode(open(ofx_file_path, "rb").read()) ofx_file_wrong = base64.b64encode(open(ofx_file_path, "rb").read())
bank_statement = self.asi_model.create( bank_statement = self.asi_model.create(
@@ -71,8 +66,8 @@ class TestOfxFile(TransactionCase):
self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong)) self.assertFalse(bank_statement._check_ofx(data_file=ofx_file_wrong))
def test_ofx_file_import(self): def test_ofx_file_import(self):
ofx_file_path = get_module_resource( ofx_file_path = file_path(
"account_statement_import_ofx", "tests/test_ofx_file/", "test_ofx.ofx" "account_statement_import_ofx/tests/test_ofx_file/test_ofx.ofx"
) )
ofx_file = base64.b64encode(open(ofx_file_path, "rb").read()) ofx_file = base64.b64encode(open(ofx_file_path, "rb").read())
bank_statement = self.asi_model.create( bank_statement = self.asi_model.create(
@@ -95,10 +90,8 @@ class TestOfxFile(TransactionCase):
self.assertEqual(line.date, datetime.date(2013, 8, 24)) self.assertEqual(line.date, datetime.date(2013, 8, 24))
def test_check_journal_bank_account(self): def test_check_journal_bank_account(self):
ofx_file_path = get_module_resource( ofx_file_path = file_path(
"account_statement_import_ofx", "account_statement_import_ofx/tests/test_ofx_file/test_ofx_iban.ofx"
"tests/test_ofx_file/",
"test_ofx_iban.ofx",
) )
ofx_file = base64.b64encode(open(ofx_file_path, "rb").read()) ofx_file = base64.b64encode(open(ofx_file_path, "rb").read())
bank_st = self.asi_model.create( bank_st = self.asi_model.create(