mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[FIX] absi- _transfer_move. Correct test and duplicate class name
This commit is contained in:
committed by
Ronald Portier (Therp BV)
parent
2552e1e979
commit
3afe152c02
@@ -1,13 +1,44 @@
|
||||
# Copyright 2020 Camptocamp SA
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class AccountBankStatementImport(models.TransientModel):
|
||||
|
||||
_inherit = "account.bank.statement.import"
|
||||
|
||||
@api.model
|
||||
def _parse_file(self, data_file):
|
||||
"""Enable testing of this functionality."""
|
||||
if self.env.context.get("account_bank_statement_import_transfer_move", False):
|
||||
return (
|
||||
None,
|
||||
"NL77ABNA0574908765",
|
||||
[
|
||||
{
|
||||
"balance_end_real": 15121.12,
|
||||
"balance_start": 15568.27,
|
||||
"date": "2014-01-05",
|
||||
"name": "1234Test/1",
|
||||
"transactions": [
|
||||
{
|
||||
"account_number": "NL46ABNA0499998748",
|
||||
"amount": -754.25,
|
||||
"date": "2014-01-05",
|
||||
"name": "Insurance policy 857239PERIOD 01.01.2014 - "
|
||||
"31.12.2014",
|
||||
"note": "MKB Insurance 859239PERIOD 01.01.2014 - "
|
||||
"31.12.2014",
|
||||
"partner_name": "INSURANCE COMPANY TESTX",
|
||||
"ref": "435005714488-ABNO33052620",
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
)
|
||||
return super()._parse_file(data_file)
|
||||
|
||||
def _create_bank_statements(self, stmts_vals):
|
||||
""" Create additional line in statement to set bank statement statement
|
||||
to 0 balance"""
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountBankStatementImport(models.Model):
|
||||
class AccountJournal(models.Model):
|
||||
|
||||
_inherit = "account.journal"
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# Copyright 2020 Camptocamp SA
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from unittest.mock import patch
|
||||
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests.common import SavepointCase
|
||||
|
||||
|
||||
@@ -35,60 +33,19 @@ class TestGenerateBankStatement(SavepointCase):
|
||||
}
|
||||
)
|
||||
|
||||
def _parse_file(self, data_file):
|
||||
"""Fake method for returning valuable data. Extracted from CAMT demo"""
|
||||
return (
|
||||
None,
|
||||
"NL77ABNA0574908765",
|
||||
[
|
||||
{
|
||||
"balance_end_real": 15121.12,
|
||||
"balance_start": 15568.27,
|
||||
"date": "2014-01-05",
|
||||
"name": "1234Test/1",
|
||||
"transactions": [
|
||||
{
|
||||
"account_number": "NL46ABNA0499998748",
|
||||
"amount": -754.25,
|
||||
"date": "2014-01-05",
|
||||
"name": "Insurance policy 857239PERIOD 01.01.2014 - "
|
||||
"31.12.2014",
|
||||
"note": "MKB Insurance 859239PERIOD 01.01.2014 - "
|
||||
"31.12.2014",
|
||||
"partner_name": "INSURANCE COMPANY TESTX",
|
||||
"ref": "435005714488-ABNO33052620",
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
def _get_bank_statements_available_import_formats(self):
|
||||
"""Fake method for returning a fake importer for not having errors."""
|
||||
return ["test"]
|
||||
|
||||
def _load_statement(self):
|
||||
module = "odoo.addons.account_bank_statement_import"
|
||||
with patch(
|
||||
module
|
||||
+ ".account_journal.AccountJournal"
|
||||
+ "._get_bank_statements_available_import_formats",
|
||||
self._get_bank_statements_available_import_formats,
|
||||
):
|
||||
with patch(
|
||||
module
|
||||
+ ".account_bank_statement_import"
|
||||
+ ".AccountBankStatementImport._parse_file",
|
||||
self._parse_file,
|
||||
):
|
||||
self.env["account.bank.statement.import"].create(
|
||||
{"attachment_ids": [(0, 0, {"name": "test file", "datas": b""})]}
|
||||
).import_file()
|
||||
bank_st_record = self.env["account.bank.statement"].search(
|
||||
[("name", "=", "1234Test/1")], limit=1
|
||||
)
|
||||
statement_lines = bank_st_record.line_ids
|
||||
return statement_lines
|
||||
"""Load fake statements, to test creation of extra line."""
|
||||
absi = self.env["account.bank.statement.import"].create(
|
||||
{"attachment_ids": [(0, 0, {"name": "test file", "datas": b""})]}
|
||||
)
|
||||
absi.with_context(
|
||||
{"account_bank_statement_import_transfer_move": True}
|
||||
).import_file()
|
||||
bank_st_record = self.env["account.bank.statement"].search(
|
||||
[("name", "=", "1234Test/1")], limit=1
|
||||
)
|
||||
statement_lines = bank_st_record.line_ids
|
||||
return statement_lines
|
||||
|
||||
def test_statement_import(self):
|
||||
self.journal.transfer_line = True
|
||||
|
||||
Reference in New Issue
Block a user