Browse Source

[MIG][12.0] account_bank_statement_import_transfer_move: backport to v12

12.0
Iryna Vushnevska 5 years ago
parent
commit
fa93e9fb59
  1. 4
      account_bank_statement_import_transfer_move/__manifest__.py
  2. 11
      account_bank_statement_import_transfer_move/models/account_bank_statement_import.py
  3. 4
      account_bank_statement_import_transfer_move/models/account_journal.py
  4. 3
      account_bank_statement_import_transfer_move/readme/DESCRIPTION.rst
  5. 20
      account_bank_statement_import_transfer_move/tests/test_statement.py

4
account_bank_statement_import_transfer_move/__manifest__.py

@ -2,12 +2,12 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Bank Account Transfer Line",
"version": "13.0.1.0.0",
"version": "12.0.1.0.0",
"category": "Account",
"website": "https://github.com/OCA/bank-statement-import",
"author": "Camptocamp, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["account_bank_statement_import"],
"depends": ["account_bank_statement_import_camt_oca"],
"data": ["view/account_journal.xml"],
}

11
account_bank_statement_import_transfer_move/models/account_bank_statement_import.py

@ -12,16 +12,14 @@ class AccountBankStatementImport(models.TransientModel):
""" Create additional line in statement to set bank statement statement
to 0 balance"""
statement_line_ids, notifications = super()._create_bank_statements(stmts_vals)
statements = self.env["account.bank.statement"].search(
[("line_ids", "in", statement_line_ids)]
)
statement_ids, notifications = super()._create_bank_statements(stmts_vals)
statements = self.env['account.bank.statement'].browse(statement_ids)
for statement in statements:
amount = sum(statement.line_ids.mapped("amount"))
if statement.journal_id.transfer_line:
if amount != 0:
amount = -amount
line = statement.line_ids.create(
statement.line_ids.create(
{
"name": statement.name,
"amount": amount,
@ -29,8 +27,7 @@ class AccountBankStatementImport(models.TransientModel):
"date": statement.date,
}
)
statement_line_ids.append(line.id)
statement.balance_end_real = statement.balance_start
else:
statement.balance_end_real = statement.balance_start + amount
return statement_line_ids, notifications
return statement_ids, notifications

4
account_bank_statement_import_transfer_move/models/account_journal.py

@ -9,6 +9,6 @@ class AccountBankStatementImport(models.Model):
_inherit = "account.journal"
transfer_line = fields.Boolean(
string="Generate line",
help="Generate transfer line on total of bank statemen import",
string="Add balance line",
help="Generate balance line on total of bank statemen import",
)

3
account_bank_statement_import_transfer_move/readme/DESCRIPTION.rst

@ -1,3 +1,4 @@
This module allows you to add generation of additional line in bank statement.
This module allows you to add generation of additional line in bank statement which will balance your bank statement total to 0.
This line can be consolidated later with different account.
To enable this option you need properly set flag on Account Journal
Configuration -> Journals -> tab Advanced Settings -> Bank statement configuration

20
account_bank_statement_import_transfer_move/tests/test_statement.py

@ -37,20 +37,20 @@ class TestGenerateBankStatement(SavepointCase):
def _load_statement(self):
# self = self.with_context(journal_id=self.journal.id)
testfile = get_module_resource(
"account_bank_statement_import_camt_oca", "test_files", "test-camt053"
)
with open(testfile, "rb") as datafile:
camt_file = base64.b64encode(datafile.read())
self.env["account.bank.statement.import"].create(
{"attachment_ids": [(0, 0, {"name": "test file", "datas": camt_file})]}
).import_file()
with open(testfile, 'rb') as datafile:
action = self.env['account.bank.statement.import'].with_context(
journal_id=self.journal.id).create({
'data_file': base64.b64encode(datafile.read())
}).import_file()
bank_st_record = self.env["account.bank.statement"].search(
[("name", "=", "1234Test/1")], limit=1
)
statement_lines = bank_st_record.line_ids
statement_lines = self.env['account.bank.statement'].browse(
action['context']['statement_ids']
).line_ids
return statement_lines

Loading…
Cancel
Save