-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] account_statement_base: add smart button on view_bank_statement…
…_form linking to journal items
- Loading branch information
1 parent
8633095
commit 30900ae
Showing
9 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_bank_statement_line |
23 changes: 23 additions & 0 deletions
23
account_statement_base/models/account_bank_statement_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from odoo import _, models | ||
|
||
|
||
class AccountBankStatement(models.Model): | ||
_inherit = "account.bank.statement" | ||
|
||
def open_entries(self): | ||
self.ensure_one() | ||
context = dict(self.env.context) | ||
context["group_by"] = ["move_name"] | ||
return { | ||
"name": _("Journal Items"), | ||
"view_mode": "tree,form", | ||
"res_model": "account.move.line", | ||
"view_id": False, | ||
"type": "ir.actions.act_window", | ||
"context": context, | ||
"domain": [ | ||
"&", | ||
("parent_state", "=", "posted"), | ||
("statement_id", "=", self.id), | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* Alexis de Lattre <alexis.delattre@akretion.com> | ||
* Sergio Bustamante <sergio.bustamante@factorlibre.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_account_statement_base |
114 changes: 114 additions & 0 deletions
114
account_statement_base/tests/test_account_statement_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
from odoo.tests import tagged | ||
|
||
from odoo.addons.account.tests.common import TestAccountReconciliationCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestReconciliationWidget(TestAccountReconciliationCommon): | ||
@classmethod | ||
def setUpClass(cls, chart_template_ref=None): | ||
super().setUpClass(chart_template_ref=chart_template_ref) | ||
cls.acc_bank_stmt_model = cls.env["account.bank.statement"] | ||
cls.account_move_model = cls.env["account.move"] | ||
cls.account_move_line_model = cls.env["account.move.line"] | ||
cls.current_assets_account = ( | ||
cls.env["account.account"] | ||
.search( | ||
[ | ||
("account_type", "=", "asset_current"), | ||
("company_id", "=", cls.company.id), | ||
], | ||
limit=1, | ||
) | ||
) | ||
cls.current_assets_account.reconcile = True | ||
cls.non_current_assets_account = ( | ||
cls.env["account.account"] | ||
.search( | ||
[ | ||
("account_type", "=", "asset_non_current"), | ||
("company_id", "=", cls.company.id), | ||
], | ||
limit=1, | ||
) | ||
) | ||
cls.non_current_assets_account.reconcile = True | ||
|
||
def test01_open_entries(self): | ||
statement = self.acc_bank_stmt_model.create( | ||
{ | ||
"name": "Test Bank Statement", | ||
} | ||
) | ||
domain = [ | ||
"&", | ||
("parent_state", "=", "posted"), | ||
("statement_id", "=", statement.id), | ||
] | ||
result = statement.open_entries() | ||
self.assertTrue(result) | ||
self.assertEqual(result.get("res_model"), "account.move.line") | ||
self.assertEqual(result.get("context").get("group_by"), ["move_name"]) | ||
self.assertEqual(result.get("domain"), domain) | ||
|
||
def test02_open_entries(self): | ||
move = self.account_move_model.create( | ||
{ | ||
"line_ids": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"account_id": self.current_assets_account.id, | ||
"name": "DEMO", | ||
"credit": 100, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"account_id": self.non_current_assets_account.id, | ||
"name": "DEMO", | ||
"debit": 100, | ||
}, | ||
), | ||
] | ||
} | ||
) | ||
move.action_post() | ||
statement = self.acc_bank_stmt_model.create( | ||
{ | ||
"name": "Test Bank Statement", | ||
"line_ids": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"date": "2024-01-01", | ||
"amount": 100.0, | ||
"payment_ref": move.name, | ||
"line_ids": [ | ||
(4, move.line_ids[0].id), | ||
], | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"date": "2024-01-01", | ||
"amount": 100.0, | ||
"payment_ref": move.name, | ||
"line_ids": [ | ||
(4, move.line_ids[1].id), | ||
], | ||
}, | ||
), | ||
], | ||
} | ||
) | ||
result = statement.open_entries() | ||
move_lines = self.env[result["res_model"]].search(result["domain"]) | ||
self.assertIn(statement.line_ids.line_ids[0], move_lines) | ||
self.assertIn(statement.line_ids.line_ids[1], move_lines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters