[FIX] account: prevent draft entry for reconciled statement
Journal entries of a bank statement can be reset to draft even if the bank statement has been validated Steps to reproduce: 1. Install Accounting 2. Go to Accounting dashboard, click on the 3 dots of Bank and go to View > Statements 3. Create a new statement with a transaction of 100, correctly set the ending balance, save and post 4. Click on reconcile then validate the reconciliation 5. Go back to the statement and validate it 6. Open the journal entry of the statement 7. You can reset it to draft but you shouldn't be able to Solution: Prevent the user from resetting a journal entry to draft if the statement has been confirmed opw-2827117 closes odoo/odoo#92713 X-original-commit: 5622bc103e063d62f75625ca413a06aa7395d654 Signed-off-by: Laurent Smet <las@odoo.com> Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
committed by
MerlinGuillaume
parent
c0cf6d79de
commit
ed586dfc68
@@ -904,7 +904,7 @@ class AccountBankStatementLine(models.Model):
|
||||
st_line_vals_to_write = {}
|
||||
|
||||
if 'state' in changed_fields:
|
||||
if (st_line.state == 'open' and move.state != 'draft') or (st_line.state == 'posted' and move.state != 'posted'):
|
||||
if (st_line.state == 'open' and move.state != 'draft') or (st_line.state in ('posted', 'confirm') and move.state != 'posted'):
|
||||
raise UserError(_(
|
||||
"You can't manually change the state of journal entry %s, as it has been created by bank "
|
||||
"statement %s."
|
||||
|
||||
@@ -1141,6 +1141,32 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
|
||||
{'debit': 0.0, 'credit': 80.0, 'amount_currency': -80.0, 'currency_id': self.currency_1.id},
|
||||
)
|
||||
|
||||
def test_reconciliation_move_draft(self):
|
||||
''' Ensures that the account move of a reconciled statement cannot be set to draft
|
||||
'''
|
||||
statement = self.env['account.bank.statement'].create({
|
||||
'name': 'test_statement',
|
||||
'date': '2019-01-01',
|
||||
'journal_id': self.bank_journal_1.id,
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'date': '2019-01-01',
|
||||
'payment_ref': 'line_1',
|
||||
'partner_id': self.partner_a.id,
|
||||
'amount': 100.0,
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
statement.button_post()
|
||||
statement.line_ids[0].reconcile([{'name': 'test', 'account_id': self.company_data['default_account_revenue'].id, 'balance': -100}])
|
||||
|
||||
statement.button_validate_or_action()
|
||||
account_move = statement.line_ids.move_id
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
account_move.button_draft()
|
||||
|
||||
def test_reconciliation_statement_line_state(self):
|
||||
''' Test the reconciliation on the bank statement line with a foreign currency on the journal:
|
||||
- Ensure the statement line is_reconciled field is well computed.
|
||||
|
||||
Reference in New Issue
Block a user