[FIX] account: Fix float division by zero in reconcile model after migration
A statement line can't have a zero amount except after a migration. In that case, the residual amount of the statement line is also zero and then, the line having the suspense account has a balance of zero. When opening the bank reconciliation widget, it leads to a float division by zero because we try to compute the paid percentage of the statement line. closes odoo/odoo#58069 Task: 2341850 X-original-commit: ecc8f8be6ee09cb0fdfae0c4b35a933541d41292 Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com> Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -772,9 +772,12 @@ class AccountBankStatementLine(models.Model):
|
||||
liquidity_lines, suspense_lines, other_lines = st_line._seek_for_lines()
|
||||
|
||||
# Compute is_reconciled
|
||||
if not st_line.id or suspense_lines:
|
||||
if not st_line.id:
|
||||
# New record: The journal items are not yet there.
|
||||
st_line.is_reconciled = False
|
||||
elif suspense_lines:
|
||||
# In case of the statement line comes from an older version, it could have a residual amount of zero.
|
||||
st_line.is_reconciled = all(suspense_line.reconciled for suspense_line in suspense_lines)
|
||||
elif st_line.currency_id.is_zero(st_line.amount):
|
||||
st_line.is_reconciled = True
|
||||
else:
|
||||
|
||||
@@ -445,6 +445,12 @@ class AccountReconcileModel(models.Model):
|
||||
# First associate with each rec models all the statement lines for which it is applicable
|
||||
lines_with_partner_per_model = defaultdict(lambda: [])
|
||||
for st_line in st_lines:
|
||||
|
||||
# Statement lines created in old versions could have a residual amount of zero. In that case, don't try to
|
||||
# match anything.
|
||||
if not st_line.amount_residual:
|
||||
continue
|
||||
|
||||
mapped_partner = (partner_map and partner_map.get(st_line.id) and self.env['res.partner'].browse(partner_map[st_line.id])) or st_line.partner_id
|
||||
|
||||
for rec_model in available_models:
|
||||
|
||||
Reference in New Issue
Block a user