[IMP] account_statement_base: add smart button on view_bank_statement_form linking to journal items
[16.0][FIX] account_statement_base: Changes post OCA CRpull/713/head
parent
6aef9ca8e5
commit
b1e635d2f1
|
@ -1,2 +1,3 @@
|
|||
from . import account_journal_dashboard
|
||||
from . import account_bank_statement_line
|
||||
from . import account_bank_statement
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
from odoo import _, models
|
||||
|
||||
|
||||
class AccountBankStatement(models.Model):
|
||||
_inherit = "account.bank.statement"
|
||||
|
||||
def action_open_statement_lines(self):
|
||||
self.ensure_one()
|
||||
if not self:
|
||||
return {}
|
||||
action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||
"account_statement_base.account_bank_statement_line_action"
|
||||
)
|
||||
action.update({"domain": [("statement_id", "=", self.id)]})
|
||||
return action
|
||||
|
||||
def open_entries(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
"name": _("Journal Items"),
|
||||
"view_mode": "tree,form",
|
||||
"res_model": "account.move.line",
|
||||
"view_id": False,
|
||||
"type": "ir.actions.act_window",
|
||||
"context": {"search_default_group_by_move": 1, "expand": 1},
|
||||
"search_view_id": self.env.ref("account.view_account_move_line_filter").id,
|
||||
"domain": [
|
||||
"&",
|
||||
("parent_state", "=", "posted"),
|
||||
("statement_id", "=", self.id),
|
||||
],
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
from . import test_account_statement_base
|
|
@ -0,0 +1,92 @@
|
|||
from odoo import Command
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.account_reconcile_model_oca.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 test_01_test_open_entries(self):
|
||||
move = self.account_move_model.create(
|
||||
{
|
||||
"line_ids": [
|
||||
Command.create(
|
||||
{
|
||||
"account_id": self.current_assets_account.id,
|
||||
"name": "DEMO",
|
||||
"credit": 100,
|
||||
}
|
||||
),
|
||||
Command.create(
|
||||
{
|
||||
"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": [
|
||||
Command.create(
|
||||
{
|
||||
"date": "2024-01-01",
|
||||
"amount": 100.0,
|
||||
"payment_ref": move.name,
|
||||
"line_ids": [Command.set([move.line_ids[0].id])],
|
||||
}
|
||||
),
|
||||
Command.create(
|
||||
{
|
||||
"date": "2024-01-01",
|
||||
"amount": 100.0,
|
||||
"payment_ref": move.name,
|
||||
"line_ids": [Command.set([move.line_ids[1].id])],
|
||||
}
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
domain = [
|
||||
"&",
|
||||
("parent_state", "=", "posted"),
|
||||
("statement_id", "=", statement.id),
|
||||
]
|
||||
result = statement.open_entries()
|
||||
move_lines = self.env[result["res_model"]].search(result["domain"])
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(result.get("res_model"), "account.move.line")
|
||||
self.assertEqual(result.get("context").get("search_default_group_by_move"), 1)
|
||||
self.assertEqual(result.get("context").get("expand"), 1)
|
||||
self.assertEqual(result.get("domain"), domain)
|
||||
self.assertIn(statement.line_ids.line_ids[0], move_lines)
|
||||
self.assertIn(statement.line_ids.line_ids[1], move_lines)
|
|
@ -28,6 +28,16 @@
|
|||
context="{'search_default_statement_id': id}"
|
||||
string="Transactions"
|
||||
/>
|
||||
<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>
|
||||
<div class="oe_title oe_inline">
|
||||
<label for="name" />
|
||||
|
|
Loading…
Reference in New Issue