summaryrefslogtreecommitdiff
path: root/addons/account
diff options
context:
space:
mode:
authorLaurent Smet <las@odoo.com>2021-01-28 12:18:52 +0000
committerLaurent Smet <las@odoo.com>2021-01-28 12:26:22 +0000
commit73ddcfbcc58b7a6542ced4bd8b20dd67c9f446ee (patch)
tree662f0f83394045c65804cfaa1654730b7d449a16 /addons/account
parentd5e503f02f94ea4125010f09b1877040c8fc68b3 (diff)
[FIX] account: Fix 'is_reconciled' flag for zero-amount statement line
When the suspense account is not reconcilable, 'suspense_lines.reconciled' always gives 'False' leading to a not reconciled statement line. closes odoo/odoo#65211 Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/account')
-rw-r--r--addons/account/models/account_bank_statement.py18
-rw-r--r--addons/account/tests/test_account_bank_statement.py20
2 files changed, 29 insertions, 9 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 805cc6b7e31..837bd1a714d 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -781,27 +781,27 @@ class AccountBankStatementLine(models.Model):
for st_line in self:
liquidity_lines, suspense_lines, other_lines = st_line._seek_for_lines()
+ # Compute residual amount
+ if st_line.to_check:
+ st_line.amount_residual = -st_line.amount_currency if st_line.foreign_currency_id else -st_line.amount
+ elif suspense_lines.account_id.reconcile:
+ st_line.amount_residual = sum(suspense_lines.mapped('amount_residual_currency'))
+ else:
+ st_line.amount_residual = sum(suspense_lines.mapped('amount_currency'))
+
# Compute is_reconciled
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)
+ st_line.is_reconciled = suspense_lines.currency_id.is_zero(st_line.amount_residual)
elif st_line.currency_id.is_zero(st_line.amount):
st_line.is_reconciled = True
else:
# The journal entry seems reconciled.
st_line.is_reconciled = True
- # Compute residual amount
- if st_line.to_check:
- st_line.amount_residual = -st_line.amount_currency if st_line.foreign_currency_id else -st_line.amount
- elif suspense_lines.account_id.reconcile:
- st_line.amount_residual = sum(suspense_lines.mapped('amount_residual_currency'))
- else:
- st_line.amount_residual = sum(suspense_lines.mapped('amount_currency'))
-
# -------------------------------------------------------------------------
# CONSTRAINT METHODS
# -------------------------------------------------------------------------
diff --git a/addons/account/tests/test_account_bank_statement.py b/addons/account/tests/test_account_bank_statement.py
index c582a6d1dc3..8d3ba4983e0 100644
--- a/addons/account/tests/test_account_bank_statement.py
+++ b/addons/account/tests/test_account_bank_statement.py
@@ -1549,3 +1549,23 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
{'amount_currency': 226.04, 'debit': 193.22, 'credit': 0.0},
{'amount_currency': -7767.70, 'debit': 0.0, 'credit': 6640.19},
])
+
+ def test_zero_amount_statement_line(self):
+ ''' Ensure the statement line is directly marked as reconciled when having an amount of zero. '''
+ self.company_data['company'].account_journal_suspense_account_id.reconcile = False
+
+ statement = self.env['account.bank.statement'].with_context(skip_check_amounts_currencies=True).create({
+ 'name': 'test_statement',
+ 'date': '2017-01-01',
+ 'journal_id': self.bank_journal_2.id,
+ 'line_ids': [
+ (0, 0, {
+ 'date': '2019-01-01',
+ 'payment_ref': "Happy new year",
+ 'amount': 0.0,
+ }),
+ ],
+ })
+ statement_line = statement.line_ids
+
+ self.assertRecordValues(statement_line, [{'is_reconciled': True, 'amount_residual': 0.0}])