Skip to content

Commit

Permalink
[FIX] absi- _transfer_move. Correct test and duplicate class name
Browse files Browse the repository at this point in the history
  • Loading branch information
NL66278 committed Jul 28, 2021
1 parent 5e43091 commit 0422046
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from odoo import fields, models


class AccountBankStatementImport(models.Model):
class AccountJournal(models.Model):

_inherit = "account.journal"

Expand Down
69 changes: 13 additions & 56 deletions account_bank_statement_import_transfer_move/tests/test_statement.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -35,60 +33,19 @@ def setUpClass(cls):
}
)

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
Expand Down

0 comments on commit 0422046

Please sign in to comment.