Skip to content

Commit 102b093

Browse files
[IMP] account_reconcile_oca: when using Reconcile Mode = 'Keep suspense accounts',
do show the reconciled move lines in the reconciliation screen, and show a button 'View moves' instead of 'View move'. This change makes it much easier for the user to review what accounts did the user choose to reconcile the statement line with.
1 parent f359658 commit 102b093

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

account_reconcile_oca/models/account_bank_statement_line.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,30 @@ class AccountBankStatementLine(models.Model):
123123
reconcile_aggregate = fields.Char(compute="_compute_reconcile_aggregate")
124124
aggregate_id = fields.Integer(compute="_compute_reconcile_aggregate")
125125
aggregate_name = fields.Char(compute="_compute_reconcile_aggregate")
126+
reconciled_move_id = fields.Many2one(
127+
"account.move",
128+
string="Reconciled Move",
129+
readonly=True,
130+
compute="_compute_reconciled_move_id",
131+
)
132+
reconciled_line_ids = fields.Many2many(
133+
"account.move.line",
134+
string="Reconciled Move Lines",
135+
readonly=True,
136+
compute="_compute_reconciled_move_id",
137+
)
138+
139+
def _compute_reconciled_move_id(self):
140+
for line in self:
141+
line.reconciled_move_id = (
142+
self.line_ids._all_reconciled_lines()
143+
.filtered(
144+
lambda line: line.move_id != self.move_id
145+
and (line.matched_debit_ids or line.matched_credit_ids)
146+
)
147+
.mapped("move_id")
148+
)
149+
line.reconciled_line_ids = line.reconciled_move_id.line_ids
126150

127151
@api.model
128152
def _reconcile_aggregate_map(self):
@@ -570,6 +594,16 @@ def action_show_move(self):
570594
)
571595
return action
572596

597+
def action_show_moves(self):
598+
"""Open the action to show the moves related to the bank statement line."""
599+
self.ensure_one()
600+
action = self.env["ir.actions.act_window"]._for_xml_id(
601+
"account.action_move_journal_line"
602+
)
603+
moves = self.move_id + self.reconciled_move_id
604+
action.update({"domain": [("id", "in", moves.ids)], "view_mode": "tree,form"})
605+
return action
606+
573607
def _inverse_reconcile_data_info(self):
574608
for record in self:
575609
record.reconcile_data = record.reconcile_data_info

account_reconcile_oca/views/account_bank_statement_line.xml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@
203203
accesskey="m"
204204
string="View move"
205205
class="btn btn-info mx-1"
206+
invisible="reconciled_line_ids"
207+
/>
208+
<button
209+
name="action_show_moves"
210+
type="object"
211+
accesskey="m"
212+
string="View moves"
213+
class="btn btn-info mx-1"
214+
invisible="not reconciled_line_ids"
206215
/>
207216
</div>
208217
</div>
@@ -221,12 +230,42 @@
221230
<field name="company_currency_id" invisible="1" />
222231
<field name="previous_manual_amount_in_currency" invisible="1" />
223232
<field name="currency_id" invisible="1" />
233+
<field name="reconcile_mode" invisible="1" />
224234
<field
225235
name="reconcile_data_info"
226236
nolabel="1"
227237
widget="account_reconcile_oca_data"
228238
class="w-100"
229239
/>
240+
<field
241+
name="reconciled_line_ids"
242+
nolabel="1"
243+
invisible="reconcile_mode != 'keep' or not reconciled_line_ids"
244+
>
245+
<list>
246+
<field name="company_currency_id" invisible="1" />
247+
<field name="currency_id" invisible="1" />
248+
<field name="account_id" />
249+
<field name="partner_id" />
250+
<field name="date" />
251+
<field name="name" />
252+
<field
253+
name="amount_currency"
254+
widget="monetary"
255+
options="{'currency_field': 'currency_id'}"
256+
/>
257+
<field
258+
name="debit"
259+
widget="monetary"
260+
options="{'currency_field': 'company_currency_id'}"
261+
/>
262+
<field
263+
name="credit"
264+
widget="monetary"
265+
options="{'currency_field': 'company_currency_id'}"
266+
/>
267+
</list>
268+
</field>
230269
<div>
231270
<field
232271
name="manual_model_id"
@@ -245,7 +284,7 @@
245284
name="add_account_move_line_id"
246285
widget="account_reconcile_oca_match"
247286
domain="[('parent_state', '=', 'posted'),('amount_residual', '!=', 0),('account_id.reconcile', '=', True), ('company_id', '=', company_id), ('statement_line_id', '!=', id)]"
248-
context="{'search_default_partner_id': partner_id, 'list_view_ref': 'account_reconcile_oca.account_move_line_tree_reconcile_view', 'search_view_ref': 'account_reconcile_oca.account_move_line_search_reconcile_view'}"
287+
context="{'search_default_partner_id': partner_id, 'list_view_ref': 'account_reconcile_oca.account_move_line_list_reconcile_view', 'search_view_ref': 'account_reconcile_oca.account_move_line_search_reconcile_view'}"
249288
/>
250289
</page>
251290
<page name="manual" string="Manual operation">

0 commit comments

Comments
 (0)