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 ee803ef
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,36 @@ def _update_move_partner(self):
return
self.partner_id = self.manual_partner_id

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 = True 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[0]
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
if move_line:
move_line_field = getattr(move_line, field, False)
if index:
move_line_field = move_line_field.id
if field == "date":
move_line_field = str(move_line_field)
if reconciled_data_field and reconciled_data_field != move_line_field:
return True

Check warning on line 472 in account_reconcile_oca/models/account_bank_statement_line.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement_line.py#L472

Added line #L472 was not covered by tests
return False

@api.depends("reconcile_data", "is_reconciled")
def _compute_reconcile_data_info(self):
for record in self:
if record._check_recompute_reconcile_data():
record.reconcile_data = False

Check warning on line 479 in account_reconcile_oca/models/account_bank_statement_line.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement_line.py#L479

Added line #L479 was not covered by tests
if record.reconcile_data:
record.reconcile_data_info = record.reconcile_data
else:
Expand Down

0 comments on commit ee803ef

Please sign in to comment.