Skip to content

Commit

Permalink
[IMP] account_statement_base: add smart button on view_bank_statement…
Browse files Browse the repository at this point in the history
…_form linking to journal items
  • Loading branch information
sergiobstoj committed May 28, 2024
1 parent 8633095 commit 30900ae
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 2 deletions.
3 changes: 2 additions & 1 deletion account_statement_base/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,6 +57,7 @@ Contributors
~~~~~~~~~~~~

* Alexis de Lattre <alexis.delattre@akretion.com>
* Sergio Bustamante <sergio.bustamante@factorlibre.com>

Maintainers
~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions account_statement_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
1 change: 1 addition & 0 deletions account_statement_base/models/__init__.py
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 account_statement_base/models/account_bank_statement_line.py
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),
],
}
1 change: 1 addition & 0 deletions account_statement_base/readme/CONTRIBUTORS.rst
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>
3 changes: 2 additions & 1 deletion account_statement_base/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1 class="title">Bank Statement Base</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:568ae5803993a7a0e41d89c734a5e0c3d5f6825d64838f16b736d8260937e16b
!! source digest: sha256:84580578e6851ceb1999289cea936101fb4a9d615fc5ba5f43f25133ee4c2166
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-reconcile/tree/16.0/account_statement_base"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_statement_base"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This is a technical module that adds the views of the <strong>Bank Statement Lines</strong> and the form view of <strong>Bank Statement</strong> (since Odoo 16.0, these views are not part of the <em>account</em> module any more).</p>
Expand Down Expand Up @@ -404,6 +404,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
<li>Sergio Bustamante &lt;<a class="reference external" href="mailto:sergio.bustamante&#64;factorlibre.com">sergio.bustamante&#64;factorlibre.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
1 change: 1 addition & 0 deletions account_statement_base/tests/__init__.py
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 account_statement_base/tests/test_account_statement_base.py
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)
12 changes: 12 additions & 0 deletions account_statement_base/views/account_bank_statement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
<field name="arch" type="xml">
<form>
<sheet string="Bank Statement">
<div class="oe_button_box" name="button_box">
<button
name="open_entries"
type="object"
class="oe_stat_button"
icon="fa-bars"
>
<div class="o_stat_info">
<span class="o_stat_text">Journal Items</span>
</div>
</button>
</div>
<group>
<group>
<field name="name" />
Expand Down

0 comments on commit 30900ae

Please sign in to comment.