From 026781ec3e133d1c7ac7468a25bb286e64e8a9b9 Mon Sep 17 00:00:00 2001
From: Goffin Simon <sig@odoo.com>
Date: Mon, 9 Apr 2018 10:36:10 +0200
Subject: [PATCH] [FIX] account: Validating a statement with old posted moves

When validating a statement with old posted moves, the lock date
was checked by function, _check_lock_date and then it was impossible
to validate the statement even if all the moves were already posted.

Backport of this commit: 86a0d31251a701da8bd1dbcb5580b958d932b33a

opw:1830804
---
 addons/account/models/account_bank_statement.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 3f75f605644a..e60c0dc09d48 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -247,7 +247,7 @@ class AccountBankStatement(models.Model):
                     raise UserError(_('All the account entries lines must be processed in order to close the statement.'))
                 moves = (moves | st_line.journal_entry_ids)
             if moves:
-                moves.post()
+                moves.filtered(lambda m: m.state != 'posted').post()
             statement.message_post(body=_('Statement %s confirmed, journal items were created.') % (statement.name,))
         statements.link_bank_to_partner()
         statements.write({'state': 'confirm', 'date_done': time.strftime("%Y-%m-%d %H:%M:%S")})
-- 
GitLab