Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,30 @@ class AccountBankStatementLine(models.Model):
reconcile_aggregate = fields.Char(compute="_compute_reconcile_aggregate")
aggregate_id = fields.Integer(compute="_compute_reconcile_aggregate")
aggregate_name = fields.Char(compute="_compute_reconcile_aggregate")
reconciled_move_id = fields.Many2one(
"account.move",
string="Reconciled Move",
readonly=True,
compute="_compute_reconciled_move_id",
)
reconciled_line_ids = fields.Many2many(
"account.move.line",
string="Reconciled Move Lines",
readonly=True,
compute="_compute_reconciled_move_id",
)

def _compute_reconciled_move_id(self):
for line in self:
line.reconciled_move_id = (
self.line_ids._all_reconciled_lines()
.filtered(
lambda line: line.move_id != self.move_id
and (line.matched_debit_ids or line.matched_credit_ids)
)
.mapped("move_id")
)
line.reconciled_line_ids = line.reconciled_move_id.line_ids

@api.model
def _reconcile_aggregate_map(self):
Expand Down Expand Up @@ -574,6 +598,16 @@ def action_show_move(self):
)
return action

def action_show_moves(self):
"""Open the action to show the moves related to the bank statement line."""
self.ensure_one()
action = self.env["ir.actions.act_window"]._for_xml_id(
"account.action_move_journal_line"
)
moves = self.move_id + self.reconciled_move_id
action.update({"domain": [("id", "in", moves.ids)], "view_mode": "tree,form"})
return action

def _inverse_reconcile_data_info(self):
for record in self:
record.reconcile_data = record.reconcile_data_info
Expand Down
39 changes: 39 additions & 0 deletions account_reconcile_oca/views/account_bank_statement_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@
accesskey="m"
string="View move"
class="btn btn-info"
attrs="{'invisible': [('reconciled_line_ids', '!=', [])]}"
/>
<button
name="action_show_moves"
type="object"
accesskey="m"
string="View moves"
class="btn btn-info"
attrs="{'invisible': [('reconciled_line_ids', '=', [])]}"
/>
</div>
</div>
Expand All @@ -214,12 +223,42 @@
<field name="company_currency_id" invisible="1" />
<field name="previous_manual_amount_in_currency" invisible="1" />
<field name="currency_id" invisible="1" />
<field name="reconcile_mode" invisible="1" />
<field
name="reconcile_data_info"
nolabel="1"
widget="account_reconcile_oca_data"
class="w-100"
/>
<field
name="reconciled_line_ids"
nolabel="1"
attrs="{'invisible': ['|', ('reconcile_mode', '!=', 'keep'), ('reconciled_line_ids', '=', [])]}"
>
<tree>
<field name="company_currency_id" invisible="1" />
<field name="currency_id" invisible="1" />
<field name="account_id" />
<field name="partner_id" />
<field name="date" />
<field name="name" />
<field
name="amount_currency"
widget="monetary"
options="{'currency_field': 'currency_id'}"
/>
<field
name="debit"
widget="monetary"
options="{'currency_field': 'company_currency_id'}"
/>
<field
name="credit"
widget="monetary"
options="{'currency_field': 'company_currency_id'}"
/>
</tree>
</field>
<div>
<field
name="manual_model_id"
Expand Down