Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] account_reconcile_oca: Improve _compute_reconcile_data_info. When changing account_id on journal item, data displayed in reconcilitation menu now is updated #773

Draft
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Draft
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
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 @@
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
Loading