[IMP] account_reconcile_model_oca: Create _get_write_off_move_move_line_dict() method to allow extension

FWP from 16.0: https://github.com/odoo/odoo/pull/188808

Related to OCA/account-reconcile#761

TT51885
pull/738/head
Víctor Martínez 2025-01-28 09:16:19 +01:00 committed by Duy (Đỗ Anh)
parent 10dcdcbc81
commit c10afe5cb8
1 changed files with 20 additions and 12 deletions

View File

@ -135,18 +135,7 @@ class AccountReconcileModel(models.Model):
if currency.is_zero(balance): if currency.is_zero(balance):
continue continue
writeoff_line = { writeoff_line = line._get_write_off_move_line_dict(balance, currency)
"name": line.label,
"balance": balance,
"debit": balance > 0 and balance or 0,
"credit": balance < 0 and -balance or 0,
"account_id": line.account_id.id,
"currency_id": currency.id,
"analytic_distribution": line.analytic_distribution,
"reconcile_model_id": self.id,
"journal_id": line.journal_id.id,
"tax_ids": [],
}
lines_vals_list.append(writeoff_line) lines_vals_list.append(writeoff_line)
residual_balance -= balance residual_balance -= balance
@ -688,3 +677,22 @@ class AccountReconcileModel(models.Model):
return {"allow_write_off", "allow_auto_reconcile"} return {"allow_write_off", "allow_auto_reconcile"}
return {"rejected"} return {"rejected"}
class AccountReconcileModelLine(models.Model):
_inherit = "account.reconcile.model.line"
def _get_write_off_move_line_dict(self, balance, currency):
self.ensure_one()
return {
"name": self.label,
"balance": balance,
"debit": balance > 0 and balance or 0,
"credit": balance < 0 and -balance or 0,
"account_id": self.account_id.id,
"currency_id": currency.id,
"analytic_distribution": self.analytic_distribution,
"reconcile_model_id": self.model_id.id,
"journal_id": self.journal_id.id,
"tax_ids": [],
}