Skip to content

Commit

Permalink
[IMP] account_reconcile_oca: Improve _compute_reconcile_data_info. Wh…
Browse files Browse the repository at this point in the history
…en changing certain fields on journal item, data displayed in reconcilitation menu is now updated
  • Loading branch information
sergiobstoj committed Jan 3, 2025
1 parent 3e6180f commit cf211f2
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,41 @@ def _update_move_partner(self):
return
self.partner_id = self.manual_partner_id

@api.depends("reconcile_data", "is_reconciled")
def _fields_to_check(self):
return ["account_id", "partner_id", "date", "name", "debit", "credit"]

def _check_recompute_reconcile_data(self):
self.ensure_one()
if self.reconcile_data:
for field in self._fields_to_check():
index = 0 if field in ["account_id", "partner_id"] else False
reconciled_data_field = self.reconcile_data.get("data", [{}])[0].get(
field, False
)
if index:
reconciled_data_field = reconciled_data_field[index]
move_line_id = self.reconcile_data.get("data", [{}])[0].get("id", False)
move_line = self.env["account.move.line"].browse(move_line_id) or False
move_line_field = getattr(move_line, field, False)
if reconciled_data_field != move_line_field:
return True
return False

@api.depends(
"reconcile_data",
"is_reconciled",
"move_id.line_ids",
"move_id.line_ids.account_id",
"move_id.line_ids.partner_id",
"move_id.line_ids.date",
"move_id.line_ids.name",
"move_id.line_ids.debit",
"move_id.line_ids.credit",
)
def _compute_reconcile_data_info(self):
for record in self:
if record._check_recompute_reconcile_data():
record.reconcile_data = False
if record.reconcile_data:
record.reconcile_data_info = record.reconcile_data
else:
Expand Down

0 comments on commit cf211f2

Please sign in to comment.