diff options
| author | Laurent Smet <las@odoo.com> | 2020-09-18 06:40:46 +0000 |
|---|---|---|
| committer | oco-odoo <oco@odoo.com> | 2020-09-18 15:35:22 +0000 |
| commit | ecc8f8be6ee09cb0fdfae0c4b35a933541d41292 (patch) | |
| tree | 263ecd7104ca073ef8ec196a43406f65616444bf /addons | |
| parent | fbe89b8617c17a3fa93970b4d706a7f0d6421ae5 (diff) | |
[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#58052
Task: 2341850
X-original-commit: bf2d76ba9e2856a5b71a3348100fdca6d068e0c0
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/models/account_bank_statement.py | 5 | ||||
| -rw-r--r-- | addons/account/models/account_reconcile_model.py | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 2e470c69ec8..0b7d783587b 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -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: diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index a5899e26eef..df8c0e8fe06 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -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: |
