diff --git a/account_statement_base/README.rst b/account_statement_base/README.rst index a7b814a40e..a5219d1398 100644 --- a/account_statement_base/README.rst +++ b/account_statement_base/README.rst @@ -7,7 +7,7 @@ Bank Statement Base !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:568ae5803993a7a0e41d89c734a5e0c3d5f6825d64838f16b736d8260937e16b + !! source digest: sha256:84580578e6851ceb1999289cea936101fb4a9d615fc5ba5f43f25133ee4c2166 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png @@ -57,6 +57,7 @@ Contributors ~~~~~~~~~~~~ * Alexis de Lattre +* Sergio Bustamante Maintainers ~~~~~~~~~~~ diff --git a/account_statement_base/__init__.py b/account_statement_base/__init__.py index e69de29bb2..0650744f6b 100644 --- a/account_statement_base/__init__.py +++ b/account_statement_base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_statement_base/models/__init__.py b/account_statement_base/models/__init__.py new file mode 100644 index 0000000000..b625fd6290 --- /dev/null +++ b/account_statement_base/models/__init__.py @@ -0,0 +1 @@ +from . import account_bank_statement_line diff --git a/account_statement_base/models/account_bank_statement_line.py b/account_statement_base/models/account_bank_statement_line.py new file mode 100644 index 0000000000..7c35bee955 --- /dev/null +++ b/account_statement_base/models/account_bank_statement_line.py @@ -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), + ], + } diff --git a/account_statement_base/readme/CONTRIBUTORS.rst b/account_statement_base/readme/CONTRIBUTORS.rst index ff65d68ce6..f17ecb2ab5 100644 --- a/account_statement_base/readme/CONTRIBUTORS.rst +++ b/account_statement_base/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Alexis de Lattre +* Sergio Bustamante diff --git a/account_statement_base/static/description/index.html b/account_statement_base/static/description/index.html index 480361997c..5e878cc48d 100644 --- a/account_statement_base/static/description/index.html +++ b/account_statement_base/static/description/index.html @@ -368,7 +368,7 @@

Bank Statement Base

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:568ae5803993a7a0e41d89c734a5e0c3d5f6825d64838f16b736d8260937e16b +!! source digest: sha256:84580578e6851ceb1999289cea936101fb4a9d615fc5ba5f43f25133ee4c2166 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Mature License: LGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runboat

This is a technical module that adds the views of the Bank Statement Lines and the form view of Bank Statement (since Odoo 16.0, these views are not part of the account module any more).

@@ -404,6 +404,7 @@

Authors

Contributors

diff --git a/account_statement_base/tests/__init__.py b/account_statement_base/tests/__init__.py new file mode 100644 index 0000000000..7543554dbb --- /dev/null +++ b/account_statement_base/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_statement_base diff --git a/account_statement_base/tests/test_account_statement_base.py b/account_statement_base/tests/test_account_statement_base.py new file mode 100644 index 0000000000..731a7ecc4b --- /dev/null +++ b/account_statement_base/tests/test_account_statement_base.py @@ -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) diff --git a/account_statement_base/views/account_bank_statement.xml b/account_statement_base/views/account_bank_statement.xml index a65f1223fe..a3e066c87b 100644 --- a/account_statement_base/views/account_bank_statement.xml +++ b/account_statement_base/views/account_bank_statement.xml @@ -18,6 +18,18 @@
+
+ +